llvm-extra-0.6.0.1: Utility functions for the llvm interface

Safe HaskellNone
LanguageHaskell98

LLVM.Extra.Control

Description

Useful control structures additionally to those in LLVM.Util.Loop.

Synopsis

Documentation

arrayLoop :: (Phi a, IsType b, Num i, IsConst i, IsInteger i, IsFirstClass i, CmpRet i, CmpResult i ~ Bool) => Value i -> Value (Ptr b) -> a -> (Value (Ptr b) -> a -> CodeGenFunction r a) -> CodeGenFunction r a Source

arrayLoop2 :: (Phi s, IsType a, IsType b, Num i, IsConst i, IsInteger i, IsFirstClass i, CmpRet i, CmpResult i ~ Bool) => Value i -> Value (Ptr a) -> Value (Ptr b) -> s -> (Value (Ptr a) -> Value (Ptr b) -> s -> CodeGenFunction r s) -> CodeGenFunction r s Source

arrayLoopWithExit :: (Phi s, IsType a, Num i, IsConst i, IsInteger i, IsFirstClass i, CmpRet i, CmpResult i ~ Bool) => Value i -> Value (Ptr a) -> s -> (Value (Ptr a) -> s -> CodeGenFunction r (Value Bool, s)) -> CodeGenFunction r (Value i, s) Source

arrayLoop2WithExit :: (Phi s, IsType a, IsType b, Num i, IsConst i, IsInteger i, IsFirstClass i, CmpRet i, CmpResult i ~ Bool) => Value i -> Value (Ptr a) -> Value (Ptr b) -> s -> (Value (Ptr a) -> Value (Ptr b) -> s -> CodeGenFunction r (Value Bool, s)) -> CodeGenFunction r (Value i, s) Source

whileLoop :: Phi a => a -> (a -> CodeGenFunction r (Value Bool)) -> (a -> CodeGenFunction r a) -> CodeGenFunction r a Source

whileLoopShared :: Phi a => a -> (a -> (CodeGenFunction r (Value Bool), CodeGenFunction r a)) -> CodeGenFunction r a Source

This is a variant of whileLoop that may be more convient, because you only need one lambda expression for both loop condition and loop body.

loopWithExit :: Phi a => a -> (a -> CodeGenFunction r (Value Bool, b)) -> (b -> CodeGenFunction r a) -> CodeGenFunction r b Source

ifThenElse :: Phi a => Value Bool -> CodeGenFunction r a -> CodeGenFunction r a -> CodeGenFunction r a Source

This construct starts new blocks, so be prepared when continueing after an ifThenElse.

class Phi a => Select a where Source

Methods

select :: Value Bool -> a -> a -> CodeGenFunction r a Source

Instances

Select () 
(IsFirstClass a, CmpRet a, (~) * (CmpResult a) Bool) => Select (Value a) 
Select a => Select (T a) 
(Select a, Select b) => Select (a, b) 
(Select a, Select b, Select c) => Select (a, b, c) 

ifThenSelect :: Select a => Value Bool -> a -> CodeGenFunction r a -> CodeGenFunction r a Source

Branch-free variant of ifThen that is faster if the enclosed block is very simply, say, if it contains at most two instructions. It can only be used as alternative to ifThen if the enclosed block is free of side effects.