llvm-extra- Utility functions for the llvm interface

Safe HaskellNone




class (Phi llvmValue, Undefined llvmValue, IsType (Struct llvmValue), IsSized (Struct llvmValue)) => C llvmValue where Source

An implementation of both MakeValueTuple and C must ensure that haskellValue is compatible with Stored (Struct haskellValue) (which we want to call llvmStruct). That is, writing and reading llvmStruct by LLVM must be the same as accessing haskellValue by Storable methods. ToDo: In future we may also require Storable constraint for llvmStruct.

We use a functional dependency in order to let type inference work nicely.

Minimal complete definition

(load | decompose), (store | compose)

Associated Types

type Struct llvmValue :: * Source


load :: Value (Ptr (Struct llvmValue)) -> CodeGenFunction r llvmValue Source

store :: llvmValue -> Value (Ptr (Struct llvmValue)) -> CodeGenFunction r () Source

decompose :: Value (Struct llvmValue) -> CodeGenFunction r llvmValue Source

compose :: llvmValue -> CodeGenFunction r (Value (Struct llvmValue)) Source


C () 
(FirstClass a, IsSized (Stored a)) => C (Value a) 
C a => C (T a) 
C a => C (T a) 
C a => C (T a) 
(C a, C b) => C (a, b) 
(C a, C b) => C (T a b) 
C n a => C (T n a) 
(C a, C b, C c) => C (a, b, c) 

modify :: C llvmValue => (llvmValue -> CodeGenFunction r llvmValue) -> Value (Ptr (Struct llvmValue)) -> CodeGenFunction r () Source

castStorablePtr :: (MakeValueTuple haskellValue, C (ValueTuple haskellValue)) => Ptr haskellValue -> Ptr (Struct (ValueTuple haskellValue)) Source

type Record r o v = Element r o v v Source

data Element r o v x Source


Functor (Element r o v) 
Applicative (Element r o v) 

element :: (C x, GetValue o n, ValueType o n ~ Struct x, GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) => (v -> x) -> n -> Element r o v x Source

loadRecord :: Record r o llvmValue -> Value (Ptr o) -> CodeGenFunction r llvmValue Source

storeRecord :: Record r o llvmValue -> llvmValue -> Value (Ptr o) -> CodeGenFunction r () Source

decomposeRecord :: Record r o llvmValue -> Value o -> CodeGenFunction r llvmValue Source

composeRecord :: IsType o => Record r o llvmValue -> llvmValue -> CodeGenFunction r (Value o) Source

loadNewtype :: C a => (a -> llvmValue) -> Value (Ptr (Struct a)) -> CodeGenFunction r llvmValue Source

storeNewtype :: C a => (llvmValue -> a) -> llvmValue -> Value (Ptr (Struct a)) -> CodeGenFunction r () Source

decomposeNewtype :: C a => (a -> llvmValue) -> Value (Struct a) -> CodeGenFunction r llvmValue Source

composeNewtype :: C a => (llvmValue -> a) -> llvmValue -> CodeGenFunction r (Value (Struct a)) Source

class (IsFirstClass llvmType, IsType (Stored llvmType)) => FirstClass llvmType Source

Minimal complete definition

fromStorable, toStorable

Associated Types

type Stored llvmType :: * Source