llvm-extra-0.12.0.1: Utility functions for the llvm interface
Safe HaskellSafe-Inferred
LanguageHaskell98

LLVM.Extra.Memory

Synopsis

Documentation

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

An implementation of both Value 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

decompose, compose

Methods

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 #

In principle it holds:

decompose struct = do
  ptr <- LLVM.alloca
  LLVM.store struct ptr
  Memory.load ptr

but alloca will blast your stack when used in a loop.

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

In principle it holds:

compose struct = do
  ptr <- LLVM.alloca
  Memory.store struct ptr
  LLVM.load ptr

but alloca will blast your stack when used in a loop.

Instances

Instances details
C () Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct () Source #

Methods

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

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

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

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

C a => C (Complex a) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (Complex a) Source #

C a => C (T a) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (T a) Source #

Methods

load :: Value (Ptr (Struct (T a))) -> CodeGenFunction r (T a) Source #

store :: T a -> Value (Ptr (Struct (T a))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (T a)) -> CodeGenFunction r (T a) Source #

compose :: T a -> CodeGenFunction r (Value (Struct (T a))) Source #

(IsType (Struct (Repr a)), IsSized (Struct (Repr a)), C a, C (Repr a)) => C (T a) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (T a) Source #

Methods

load :: Value (Ptr (Struct (T a))) -> CodeGenFunction r (T a) Source #

store :: T a -> Value (Ptr (Struct (T a))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (T a)) -> CodeGenFunction r (T a) Source #

compose :: T a -> CodeGenFunction r (Value (Struct (T a))) Source #

C a => C (T a) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (T a) Source #

Methods

load :: Value (Ptr (Struct (T a))) -> CodeGenFunction r (T a) Source #

store :: T a -> Value (Ptr (Struct (T a))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (T a)) -> CodeGenFunction r (T a) Source #

compose :: T a -> CodeGenFunction r (Value (Struct (T a))) Source #

(Phi s, Undefined s, StructFields (StructStruct s), ConvertStruct (StructStruct s) D0 s) => C (T s) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (T s) Source #

Methods

load :: Value (Ptr (Struct (T s))) -> CodeGenFunction r (T s) Source #

store :: T s -> Value (Ptr (Struct (T s))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (T s)) -> CodeGenFunction r (T s) Source #

compose :: T s -> CodeGenFunction r (Value (Struct (T s))) Source #

IsSized a => C (Value a) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (Value a) Source #

(Natural n, C a, Natural (FromUnary n), Natural (FromUnary n :*: SizeOf (Struct a)), IsFirstClass (Struct a)) => C (T n a) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (T n a) Source #

Methods

load :: Value (Ptr (Struct (T n a))) -> CodeGenFunction r (T n a) Source #

store :: T n a -> Value (Ptr (Struct (T n a))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (T n a)) -> CodeGenFunction r (T n a) Source #

compose :: T n a -> CodeGenFunction r (Value (Struct (T n a))) Source #

(C a, C b) => C (T a b) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (T a b) Source #

Methods

load :: Value (Ptr (Struct (T a b))) -> CodeGenFunction r (T a b) Source #

store :: T a b -> Value (Ptr (Struct (T a b))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (T a b)) -> CodeGenFunction r (T a b) Source #

compose :: T a b -> CodeGenFunction r (Value (Struct (T a b))) Source #

(IsType (Struct (Repr n a)), IsSized (Struct (Repr n a)), Positive n, C a, C (Repr n a)) => C (T n a) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (T n a) Source #

Methods

load :: Value (Ptr (Struct (T n a))) -> CodeGenFunction r (T n a) Source #

store :: T n a -> Value (Ptr (Struct (T n a))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (T n a)) -> CodeGenFunction r (T n a) Source #

compose :: T n a -> CodeGenFunction r (Value (Struct (T n a))) Source #

(C a, C b) => C (a, b) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (a, b) Source #

Methods

load :: Value (Ptr (Struct (a, b))) -> CodeGenFunction r (a, b) Source #

store :: (a, b) -> Value (Ptr (Struct (a, b))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (a, b)) -> CodeGenFunction r (a, b) Source #

compose :: (a, b) -> CodeGenFunction r (Value (Struct (a, b))) Source #

(C a, C b, C c) => C (a, b, c) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (a, b, c) Source #

Methods

load :: Value (Ptr (Struct (a, b, c))) -> CodeGenFunction r (a, b, c) Source #

store :: (a, b, c) -> Value (Ptr (Struct (a, b, c))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (a, b, c)) -> CodeGenFunction r (a, b, c) Source #

compose :: (a, b, c) -> CodeGenFunction r (Value (Struct (a, b, c))) Source #

(C a, C b, C c, C d) => C (a, b, c, d) Source # 
Instance details

Defined in LLVM.Extra.Memory

Associated Types

type Struct (a, b, c, d) Source #

Methods

load :: Value (Ptr (Struct (a, b, c, d))) -> CodeGenFunction r (a, b, c, d) Source #

store :: (a, b, c, d) -> Value (Ptr (Struct (a, b, c, d))) -> CodeGenFunction r () Source #

decompose :: Value (Struct (a, b, c, d)) -> CodeGenFunction r (a, b, c, d) Source #

compose :: (a, b, c, d) -> CodeGenFunction r (Value (Struct (a, b, c, d))) Source #

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

type family Struct llvmValue Source #

Instances

Instances details
type Struct () Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct () = Struct ()
type Struct (Complex a) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (Complex a) = Struct (Struct a, (Struct a, ()))
type Struct (T a) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (T a) = Struct (Bool, (Struct a, ()))
type Struct (T a) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (T a) = Struct (Repr a)
type Struct (T a) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (T a) = Struct a
type Struct (T s) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (T s)
type Struct (Value a) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (Value a) = a
type Struct (T n a) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (T n a) = Array (FromUnary n) (Struct a)
type Struct (T a b) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (T a b) = Struct (Bool, (Struct a, (Struct b, ())))
type Struct (T n a) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (T n a) = Struct (Repr n a)
type Struct (a, b) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (a, b) = Struct (Struct a, (Struct b, ()))
type Struct (a, b, c) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (a, b, c) = Struct (Struct a, (Struct b, (Struct c, ())))
type Struct (a, b, c, d) Source # 
Instance details

Defined in LLVM.Extra.Memory

type Struct (a, b, c, d) = Struct (Struct a, (Struct b, (Struct c, (Struct d, ()))))

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

data Element r o v x Source #

Instances

Instances details
Applicative (Element r o v) Source # 
Instance details

Defined in LLVM.Extra.Memory

Methods

pure :: a -> Element r o v a #

(<*>) :: Element r o v (a -> b) -> Element r o v a -> Element r o v b #

liftA2 :: (a -> b -> c) -> Element r o v a -> Element r o v b -> Element r o v c #

(*>) :: Element r o v a -> Element r o v b -> Element r o v b #

(<*) :: Element r o v a -> Element r o v b -> Element r o v a #

Functor (Element r o v) Source # 
Instance details

Defined in LLVM.Extra.Memory

Methods

fmap :: (a -> b) -> Element r o v a -> Element r o v b #

(<$) :: a -> Element r o v b -> Element r o v a #

element :: (C x, IsType o, 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 #