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

Safe HaskellNone
LanguageHaskell2010

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 # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

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

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

Defined in LLVM.IRBuilder.Monad

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 # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

get :: IRBuilderT m s #

put :: s -> IRBuilderT m () #

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

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

Defined in LLVM.IRBuilder.Monad

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 # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

throwError :: e -> IRBuilderT m a #

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

Monad m => Monad (IRBuilderT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

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 # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

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

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

MonadFix m => MonadFix (IRBuilderT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

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

MonadFail m => MonadFail (IRBuilderT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

fail :: String -> IRBuilderT m a #

Monad m => Applicative (IRBuilderT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

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 # 
Instance details

Defined in LLVM.IRBuilder.Monad

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 # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

mzero :: IRBuilderT m a #

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

MonadIO m => MonadIO (IRBuilderT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

liftIO :: IO a -> IRBuilderT m a #

MonadCont m => MonadCont (IRBuilderT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

Methods

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

Monad m => MonadIRBuilder (IRBuilderT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

class Monad m => MonadIRBuilder m where Source #

Instances
MonadIRBuilder m => MonadIRBuilder (ListT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

MonadIRBuilder m => MonadIRBuilder (MaybeT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

Monad m => MonadIRBuilder (IRBuilderT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

MonadIRBuilder m => MonadIRBuilder (IdentityT m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

MonadIRBuilder m => MonadIRBuilder (ExceptT e m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

MonadIRBuilder m => MonadIRBuilder (StateT s m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

MonadIRBuilder m => MonadIRBuilder (StateT s m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

(Monoid w, MonadIRBuilder m) => MonadIRBuilder (WriterT w m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

(Monoid w, MonadIRBuilder m) => MonadIRBuilder (WriterT w m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

MonadIRBuilder m => MonadIRBuilder (ContT r m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

MonadIRBuilder m => MonadIRBuilder (ReaderT r m) Source # 
Instance details

Defined in LLVM.IRBuilder.Monad

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

Defined in LLVM.IRBuilder.Monad

Methods

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

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

Defined in LLVM.IRBuilder.Monad

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

ensureBlock :: MonadIRBuilder m => m () Source #

If no partial block exists, create a new block with a fresh label.

This is useful if you want to ensure that the label for the block is assigned before another label which is not possible with modifyBlock.

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).

currentBlock :: MonadIRBuilder m => m Name Source #

Get the name of the currently active block.

This function will throw an error if there is no active block. The only situation in which this can occur is if it is called before any call to block and before emitting any instructions.