llvm-hs-pure-5.1.2: Pure Haskell LLVM functionality (no FFI).

Safe HaskellNone
LanguageHaskell98

LLVM.IRBuilder.Monad

Contents

Synopsis

Documentation

newtype IRBuilderT m a Source #

This provides a uniform API for creating instructions and inserting them into a basic block: either at the end of a BasicBlock, or at a specific location in a block.

Constructors

IRBuilderT 

Instances

MonadTrans IRBuilderT Source # 

Methods

lift :: Monad m => m a -> IRBuilderT m a #

MonadWriter w m => MonadWriter w (IRBuilderT m) Source # 

Methods

writer :: (a, w) -> IRBuilderT m a #

tell :: w -> IRBuilderT m () #

listen :: IRBuilderT m a -> IRBuilderT m (a, w) #

pass :: IRBuilderT m (a, w -> w) -> IRBuilderT m a #

MonadState s m => MonadState s (IRBuilderT m) Source # 

Methods

get :: IRBuilderT m s #

put :: s -> IRBuilderT m () #

state :: (s -> (a, s)) -> IRBuilderT m a #

MonadReader r m => MonadReader r (IRBuilderT m) Source # 

Methods

ask :: IRBuilderT m r #

local :: (r -> r) -> IRBuilderT m a -> IRBuilderT m a #

reader :: (r -> a) -> IRBuilderT m a #

MonadError e m => MonadError e (IRBuilderT m) Source # 

Methods

throwError :: e -> IRBuilderT m a #

catchError :: IRBuilderT m a -> (e -> IRBuilderT m a) -> IRBuilderT m a #

Monad m => Monad (IRBuilderT m) Source # 

Methods

(>>=) :: IRBuilderT m a -> (a -> IRBuilderT m b) -> IRBuilderT m b #

(>>) :: IRBuilderT m a -> IRBuilderT m b -> IRBuilderT m b #

return :: a -> IRBuilderT m a #

fail :: String -> IRBuilderT m a #

Functor m => Functor (IRBuilderT m) Source # 

Methods

fmap :: (a -> b) -> IRBuilderT m a -> IRBuilderT m b #

(<$) :: a -> IRBuilderT m b -> IRBuilderT m a #

MonadFix m => MonadFix (IRBuilderT m) Source # 

Methods

mfix :: (a -> IRBuilderT m a) -> IRBuilderT m a #

MonadFail m => MonadFail (IRBuilderT m) Source # 

Methods

fail :: String -> IRBuilderT m a #

Monad m => Applicative (IRBuilderT m) Source # 

Methods

pure :: a -> IRBuilderT m a #

(<*>) :: IRBuilderT m (a -> b) -> IRBuilderT m a -> IRBuilderT m b #

liftA2 :: (a -> b -> c) -> IRBuilderT m a -> IRBuilderT m b -> IRBuilderT m c #

(*>) :: IRBuilderT m a -> IRBuilderT m b -> IRBuilderT m b #

(<*) :: IRBuilderT m a -> IRBuilderT m b -> IRBuilderT m a #

MonadPlus m => Alternative (IRBuilderT m) Source # 

Methods

empty :: IRBuilderT m a #

(<|>) :: IRBuilderT m a -> IRBuilderT m a -> IRBuilderT m a #

some :: IRBuilderT m a -> IRBuilderT m [a] #

many :: IRBuilderT m a -> IRBuilderT m [a] #

MonadPlus m => MonadPlus (IRBuilderT m) Source # 

Methods

mzero :: IRBuilderT m a #

mplus :: IRBuilderT m a -> IRBuilderT m a -> IRBuilderT m a #

MonadIO m => MonadIO (IRBuilderT m) Source # 

Methods

liftIO :: IO a -> IRBuilderT m a #

MonadCont m => MonadCont (IRBuilderT m) Source # 

Methods

callCC :: ((a -> IRBuilderT m b) -> IRBuilderT m a) -> IRBuilderT m a #

Monad m => MonadIRBuilder (IRBuilderT m) Source # 

class Monad m => MonadIRBuilder m where Source #

Instances

MonadIRBuilder m => MonadIRBuilder (ListT m) Source # 
MonadIRBuilder m => MonadIRBuilder (MaybeT m) Source # 
Monad m => MonadIRBuilder (IRBuilderT m) Source # 
MonadIRBuilder m => MonadIRBuilder (ExceptT e m) Source # 
MonadIRBuilder m => MonadIRBuilder (StateT s m) Source # 
MonadIRBuilder m => MonadIRBuilder (StateT s m) Source # 
(Monoid w, MonadIRBuilder m) => MonadIRBuilder (WriterT w m) Source # 
(Monoid w, MonadIRBuilder m) => MonadIRBuilder (WriterT w m) Source # 
MonadIRBuilder m => MonadIRBuilder (IdentityT * m) Source # 
MonadIRBuilder m => MonadIRBuilder (ContT * r m) Source # 
MonadIRBuilder m => MonadIRBuilder (ReaderT * r m) Source # 
(MonadIRBuilder m, Monoid w) => MonadIRBuilder (RWST r w s m) Source # 

Methods

liftIRState :: State IRBuilderState a -> RWST r w s m a Source #

(MonadIRBuilder m, Monoid w) => MonadIRBuilder (RWST r w s m) Source # 

Methods

liftIRState :: State IRBuilderState a -> RWST r w s m a Source #

data PartialBlock Source #

A partially constructed block as a sequence of instructions

runIRBuilder :: IRBuilderState -> IRBuilder a -> (a, [BasicBlock]) Source #

Evaluate IRBuilder to a result and a list of basic blocks

runIRBuilderT :: Monad m => IRBuilderState -> IRBuilderT m a -> m (a, [BasicBlock]) Source #

Evaluate IRBuilderT to a result and a list of basic blocks

execIRBuilder :: IRBuilderState -> IRBuilder a -> [BasicBlock] Source #

Evaluate IRBuilder to a list of basic blocks

execIRBuilderT :: Monad m => IRBuilderState -> IRBuilderT m a -> m [BasicBlock] Source #

Evaluate IRBuilderT to a list of basic blocks

Low-level functionality

fresh :: MonadIRBuilder m => m Name Source #

Generate a fresh name. The resulting name is numbered or based on the name suggested with named if that's used.

freshName :: MonadIRBuilder m => ShortByteString -> m Name Source #

Generate a fresh name from a name suggestion

freshUnName :: MonadIRBuilder m => m Name Source #

Generate a fresh numbered name

emitInstr Source #

Arguments

:: MonadIRBuilder m 
=> Type

Return type

-> Instruction 
-> m Operand 

Emit instruction

emitInstrVoid :: MonadIRBuilder m => Instruction -> m () Source #

Emit instruction that returns void

emitTerm :: MonadIRBuilder m => Terminator -> m () Source #

Emit terminator

emitBlockStart :: MonadIRBuilder m => Name -> m () Source #

Starts a new block labelled using the given name and ends the previous one. The name is assumed to be fresh.

High-level functionality

block :: MonadIRBuilder m => m Name Source #

Starts a new block and ends the previous one

named :: MonadIRBuilder m => m r -> ShortByteString -> m r Source #

ir named name executes the IRBuilder ir using name as the base name whenever a fresh local name is generated. Collisions are avoided by appending numbers (first "name", then "name1", "name2", and so on).