| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Language.QBE.Simulator
Description
This module describes the semantics of the QBE
intermediate representation using an abstract Simulator monad.
Specifically, it abstractly describes the semantics of QBE's control-flow
constructs (such as functions, statements, and blocks) and instructions
using the primitives of this monad. The semantics can then be concretely
instantiated (refer to the instance of the Simulator monad). This idea
is inspired by the paper Flexible Instruction-Set Semantics via Abstract Monads.
Documentation
execStmt :: Simulator m v => Statement -> m () Source #
Execute a Statement, usually a sequence of Instruction.
Therefore, this function iteratively calls execInstr in the common case.
execBlock :: Simulator m v => Maybe BlockIdent -> Block -> m (BlockResult v) Source #
Execute a BasicBlock, as represented by Block, by iteratively
invoking execStmt. If this isn't the first executed BasicBlock within a a
Function, then the BlockIdent of the previously executed
BasicBlock should be provided. This is required to properly execute phi
instructions.
execFunc :: Simulator m v => FuncDef -> [v] -> m (Maybe v) Source #
Execute a FuncDef until function return. If the function requires arguments to
be passed to it, these must be provided as a list. Limited sanity checking is performed
to ensure that the provided arguments match the declared function parameters. The return
value of execFunc is the return value of the executed FuncDef. If the function
has no return value, Nothing is returned here.