Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype IRBuilderT m a = IRBuilderT {
- unIRBuilderT :: StateT IRBuilderState m a
- type IRBuilder = IRBuilderT Identity
- class Monad m => MonadIRBuilder m where
- liftIRState :: State IRBuilderState a -> m a
- data PartialBlock = PartialBlock {}
- emptyPartialBlock :: Name -> PartialBlock
- data IRBuilderState = IRBuilderState {}
- emptyIRBuilder :: IRBuilderState
- runIRBuilder :: IRBuilderState -> IRBuilder a -> (a, [BasicBlock])
- runIRBuilderT :: Monad m => IRBuilderState -> IRBuilderT m a -> m (a, [BasicBlock])
- execIRBuilder :: IRBuilderState -> IRBuilder a -> [BasicBlock]
- execIRBuilderT :: Monad m => IRBuilderState -> IRBuilderT m a -> m [BasicBlock]
- ensureBlock :: MonadIRBuilder m => m ()
- modifyBlock :: MonadIRBuilder m => (PartialBlock -> PartialBlock) -> m ()
- fresh :: MonadIRBuilder m => m Name
- freshName :: MonadIRBuilder m => ShortByteString -> m Name
- freshUnName :: MonadIRBuilder m => m Name
- emitInstr :: MonadIRBuilder m => Type -> Instruction -> m Operand
- emitInstrVoid :: MonadIRBuilder m => Instruction -> m ()
- emitTerm :: MonadIRBuilder m => Terminator -> m ()
- emitBlockStart :: MonadIRBuilder m => Name -> m ()
- block :: MonadIRBuilder m => m Name
- named :: MonadIRBuilder m => m r -> ShortByteString -> m r
- currentBlock :: MonadIRBuilder m => m Name
- hasTerminator :: MonadIRBuilder m => m Bool
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.
Instances
type IRBuilder = IRBuilderT Identity Source #
class Monad m => MonadIRBuilder m where Source #
Nothing
liftIRState :: State IRBuilderState a -> m a Source #
liftIRState :: (MonadTrans t, MonadIRBuilder m1, m ~ t m1) => State IRBuilderState a -> m a Source #
Instances
data PartialBlock Source #
A partially constructed block as a sequence of instructions
emptyPartialBlock :: Name -> PartialBlock Source #
data IRBuilderState Source #
Builder monad state
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
.
modifyBlock :: MonadIRBuilder m => (PartialBlock -> PartialBlock) -> m () Source #
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
:: 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 #
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.
hasTerminator :: MonadIRBuilder m => m Bool Source #
Find out if the currently active block has a terminator.
This function will fail under the same condition as currentBlock