Copyright | (c) Galois Inc 2014-2018 |
---|---|
License | BSD3 |
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Stability | provisional |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module provides a monadic interface for constructing control flow graph expressions. The goal is to make it easy to convert languages into CFGs.
The CFGs generated by this interface are similar to, but not quite the same as, the CFGs defined in Lang.Crucible.CFG.Core. The module Lang.Crucible.CFG.SSAConversion contains code that converts the CFGs produced by this interface into Core CFGs in SSA form.
Synopsis
- data Generator ext s (t :: Type -> Type) (ret :: CrucibleType) m a
- type FunctionDef ext t init ret m = forall s. Assignment (Atom s) init -> (t s, Generator ext s t ret m (Expr ext s ret))
- defineFunction :: (Monad m, IsSyntaxExtension ext) => Position -> Some (NonceGenerator m) -> FnHandle init ret -> FunctionDef ext t init ret m -> m (SomeCFG ext init ret, [AnyCFG ext])
- defineFunctionOpt :: (Monad m, IsSyntaxExtension ext) => Position -> Some (NonceGenerator m) -> FnHandle init ret -> FunctionDef ext t init ret m -> (forall s. NonceGenerator m s -> CFG ext s init ret -> m (CFG ext s init ret)) -> m (SomeCFG ext init ret, [AnyCFG ext])
- getPosition :: Generator ext s t ret m Position
- setPosition :: Position -> Generator ext s t ret m ()
- withPosition :: Monad m => Position -> Generator ext s t ret m a -> Generator ext s t ret m a
- newReg :: (Monad m, IsSyntaxExtension ext) => Expr ext s tp -> Generator ext s t ret m (Reg s tp)
- newUnassignedReg :: Monad m => TypeRepr tp -> Generator ext s t ret m (Reg s tp)
- readReg :: (Monad m, IsSyntaxExtension ext) => Reg s tp -> Generator ext s t ret m (Expr ext s tp)
- assignReg :: (Monad m, IsSyntaxExtension ext) => Reg s tp -> Expr ext s tp -> Generator ext s t ret m ()
- modifyReg :: (Monad m, IsSyntaxExtension ext) => Reg s tp -> (Expr ext s tp -> Expr ext s tp) -> Generator ext s t ret m ()
- modifyRegM :: (Monad m, IsSyntaxExtension ext) => Reg s tp -> (Expr ext s tp -> Generator ext s t ret m (Expr ext s tp)) -> Generator ext s t ret m ()
- readGlobal :: (Monad m, IsSyntaxExtension ext) => GlobalVar tp -> Generator ext s t ret m (Expr ext s tp)
- writeGlobal :: (Monad m, IsSyntaxExtension ext) => GlobalVar tp -> Expr ext s tp -> Generator ext s t ret m ()
- newRef :: (Monad m, IsSyntaxExtension ext) => Expr ext s tp -> Generator ext s t ret m (Expr ext s (ReferenceType tp))
- newEmptyRef :: (Monad m, IsSyntaxExtension ext) => TypeRepr tp -> Generator ext s t ret m (Expr ext s (ReferenceType tp))
- readRef :: (Monad m, IsSyntaxExtension ext) => Expr ext s (ReferenceType tp) -> Generator ext s t ret m (Expr ext s tp)
- writeRef :: (Monad m, IsSyntaxExtension ext) => Expr ext s (ReferenceType tp) -> Expr ext s tp -> Generator ext s t ret m ()
- dropRef :: (Monad m, IsSyntaxExtension ext) => Expr ext s (ReferenceType tp) -> Generator ext s t ret m ()
- call :: (Monad m, IsSyntaxExtension ext) => Expr ext s (FunctionHandleType args ret) -> Assignment (Expr ext s) args -> Generator ext s t r m (Expr ext s ret)
- assertExpr :: (Monad m, IsSyntaxExtension ext) => Expr ext s BoolType -> Expr ext s (StringType Unicode) -> Generator ext s t ret m ()
- assumeExpr :: (Monad m, IsSyntaxExtension ext) => Expr ext s BoolType -> Expr ext s (StringType Unicode) -> Generator ext s t ret m ()
- addPrintStmt :: (Monad m, IsSyntaxExtension ext) => Expr ext s (StringType Unicode) -> Generator ext s t ret m ()
- addBreakpointStmt :: (Monad m, IsSyntaxExtension ext) => Text -> Assignment (Value s) args -> Generator ext s t r m ()
- extensionStmt :: (Monad m, IsSyntaxExtension ext) => StmtExtension ext (Expr ext s) tp -> Generator ext s t ret m (Expr ext s tp)
- mkAtom :: (Monad m, IsSyntaxExtension ext) => Expr ext s tp -> Generator ext s t ret m (Atom s tp)
- mkFresh :: (Monad m, IsSyntaxExtension ext) => BaseTypeRepr tp -> Maybe SolverSymbol -> Generator ext s t ret m (Atom s (BaseToType tp))
- mkFreshFloat :: (Monad m, IsSyntaxExtension ext) => FloatInfoRepr fi -> Maybe SolverSymbol -> Generator ext s t ret m (Atom s (FloatType fi))
- forceEvaluation :: (Monad m, IsSyntaxExtension ext) => Expr ext s tp -> Generator ext s t ret m (Expr ext s tp)
- newLabel :: Monad m => Generator ext s t ret m (Label s)
- newLambdaLabel :: Monad m => KnownRepr TypeRepr tp => Generator ext s t ret m (LambdaLabel s tp)
- newLambdaLabel' :: Monad m => TypeRepr tp -> Generator ext s t ret m (LambdaLabel s tp)
- currentBlockID :: Generator ext s t ret m (BlockID s)
- jump :: (Monad m, IsSyntaxExtension ext) => Label s -> Generator ext s t ret m a
- jumpToLambda :: (Monad m, IsSyntaxExtension ext) => LambdaLabel s tp -> Expr ext s tp -> Generator ext s t ret m a
- branch :: (Monad m, IsSyntaxExtension ext) => Expr ext s BoolType -> Label s -> Label s -> Generator ext s t ret m a
- returnFromFunction :: (Monad m, IsSyntaxExtension ext) => Expr ext s ret -> Generator ext s t ret m a
- reportError :: (Monad m, IsSyntaxExtension ext) => Expr ext s (StringType Unicode) -> Generator ext s t ret m a
- branchMaybe :: (Monad m, IsSyntaxExtension ext) => Expr ext s (MaybeType tp) -> LambdaLabel s tp -> Label s -> Generator ext s t ret m a
- branchVariant :: (Monad m, IsSyntaxExtension ext) => Expr ext s (VariantType varctx) -> Assignment (LambdaLabel s) varctx -> Generator ext s t ret m a
- tailCall :: (Monad m, IsSyntaxExtension ext) => Expr ext s (FunctionHandleType args ret) -> Assignment (Expr ext s) args -> Generator ext s t ret m a
- defineBlock :: (Monad m, IsSyntaxExtension ext) => Label s -> (forall a. Generator ext s t ret m a) -> Generator ext s t ret m ()
- defineLambdaBlock :: (Monad m, IsSyntaxExtension ext) => LambdaLabel s tp -> (forall a. Expr ext s tp -> Generator ext s t ret m a) -> Generator ext s t ret m ()
- defineBlockLabel :: (Monad m, IsSyntaxExtension ext) => (forall a. Generator ext s t ret m a) -> Generator ext s t ret m (Label s)
- recordCFG :: AnyCFG ext -> Generator ext s t ret m ()
- continue :: (Monad m, IsSyntaxExtension ext) => Label s -> (forall a. Generator ext s t ret m a) -> Generator ext s t ret m ()
- continueLambda :: (Monad m, IsSyntaxExtension ext) => LambdaLabel s tp -> (forall a. Generator ext s t ret m a) -> Generator ext s t ret m (Expr ext s tp)
- whenCond :: (Monad m, IsSyntaxExtension ext) => Expr ext s BoolType -> Generator ext s t ret m () -> Generator ext s t ret m ()
- unlessCond :: (Monad m, IsSyntaxExtension ext) => Expr ext s BoolType -> Generator ext s t ret m () -> Generator ext s t ret m ()
- ifte :: (Monad m, IsSyntaxExtension ext, KnownRepr TypeRepr tp) => Expr ext s BoolType -> Generator ext s t ret m (Expr ext s tp) -> Generator ext s t ret m (Expr ext s tp) -> Generator ext s t ret m (Expr ext s tp)
- ifte' :: (Monad m, IsSyntaxExtension ext) => TypeRepr tp -> Expr ext s BoolType -> Generator ext s t ret m (Expr ext s tp) -> Generator ext s t ret m (Expr ext s tp) -> Generator ext s t ret m (Expr ext s tp)
- ifte_ :: (Monad m, IsSyntaxExtension ext) => Expr ext s BoolType -> Generator ext s t ret m () -> Generator ext s t ret m () -> Generator ext s t ret m ()
- ifteM :: (Monad m, IsSyntaxExtension ext, KnownRepr TypeRepr tp) => Generator ext s t ret m (Expr ext s BoolType) -> Generator ext s t ret m (Expr ext s tp) -> Generator ext s t ret m (Expr ext s tp) -> Generator ext s t ret m (Expr ext s tp)
- data MatchMaybe j r = MatchMaybe {}
- caseMaybe :: (Monad m, IsSyntaxExtension ext) => Expr ext s (MaybeType tp) -> TypeRepr r -> MatchMaybe (Expr ext s tp) (Generator ext s t ret m (Expr ext s r)) -> Generator ext s t ret m (Expr ext s r)
- caseMaybe_ :: (Monad m, IsSyntaxExtension ext) => Expr ext s (MaybeType tp) -> MatchMaybe (Expr ext s tp) (Generator ext s t ret m ()) -> Generator ext s t ret m ()
- fromJustExpr :: (Monad m, IsSyntaxExtension ext) => Expr ext s (MaybeType tp) -> Expr ext s (StringType Unicode) -> Generator ext s t ret m (Expr ext s tp)
- assertedJustExpr :: (Monad m, IsSyntaxExtension ext) => Expr ext s (MaybeType tp) -> Expr ext s (StringType Unicode) -> Generator ext s t ret m (Expr ext s tp)
- while :: (Monad m, IsSyntaxExtension ext) => (Position, Generator ext s t ret m (Expr ext s BoolType)) -> (Position, Generator ext s t ret m ()) -> Generator ext s t ret m ()
- data Ctx k
- data Position
- data Stmt ext s
- = forall tp. SetReg !(Reg s tp) !(Atom s tp)
- | forall tp. WriteGlobal !(GlobalVar tp) !(Atom s tp)
- | forall tp. WriteRef !(Atom s (ReferenceType tp)) !(Atom s tp)
- | forall tp. DropRef !(Atom s (ReferenceType tp))
- | forall tp. DefineAtom !(Atom s tp) !(AtomValue ext s tp)
- | Print !(Atom s (StringType Unicode))
- | Assert !(Atom s BoolType) !(Atom s (StringType Unicode))
- | Assume !(Atom s BoolType) !(Atom s (StringType Unicode))
- | forall args. Breakpoint BreakpointName !(Assignment (Value s) args)
- data Value s (tp :: CrucibleType)
- data Atom s (tp :: CrucibleType) = Atom {
- atomPosition :: !Position
- atomId :: !(Nonce s tp)
- atomSource :: !(AtomSource s tp)
- typeOfAtom :: !(TypeRepr tp)
- newtype Label s = Label {}
- data Expr ext s (tp :: CrucibleType)
- data CFG ext s (init :: Ctx CrucibleType) (ret :: CrucibleType) = CFG {}
- data BlockID (s :: Type) where
- data GlobalVar (tp :: CrucibleType) = GlobalVar {
- globalNonce :: !(Nonce GlobalNonceGenerator tp)
- globalName :: !Text
- globalType :: !(TypeRepr tp)
- newtype BreakpointName = BreakpointName {}
- data SomeCFG ext init ret = forall s. SomeCFG !(CFG ext s init ret)
- data Block ext s (ret :: CrucibleType)
- data TermStmt s (ret :: CrucibleType) where
- Jump :: !(Label s) -> TermStmt s ret
- Br :: !(Atom s BoolType) -> !(Label s) -> !(Label s) -> TermStmt s ret
- MaybeBranch :: !(TypeRepr tp) -> !(Atom s (MaybeType tp)) -> !(LambdaLabel s tp) -> !(Label s) -> TermStmt s ret
- VariantElim :: !(CtxRepr varctx) -> !(Atom s (VariantType varctx)) -> !(Assignment (LambdaLabel s) varctx) -> TermStmt s ret
- Return :: !(Atom s ret) -> TermStmt s ret
- TailCall :: !(Atom s (FunctionHandleType args ret)) -> !(CtxRepr args) -> !(Assignment (Atom s) args) -> TermStmt s ret
- ErrorStmt :: !(Atom s (StringType Unicode)) -> TermStmt s ret
- Output :: !(LambdaLabel s tp) -> !(Atom s tp) -> TermStmt s ret
- data Reg s (tp :: CrucibleType) = Reg {}
- data LambdaLabel (s :: Type) (tp :: CrucibleType) = LambdaLabel {
- lambdaId :: !(Nonce s tp)
- lambdaAtom :: Atom s tp
- data AtomSource s (tp :: CrucibleType)
- = Assigned
- | FnInput
- | LambdaArg !(LambdaLabel s tp)
- data AtomValue ext s (tp :: CrucibleType) where
- EvalApp :: !(App ext (Atom s) tp) -> AtomValue ext s tp
- ReadReg :: !(Reg s tp) -> AtomValue ext s tp
- EvalExt :: !(StmtExtension ext (Atom s) tp) -> AtomValue ext s tp
- ReadGlobal :: !(GlobalVar tp) -> AtomValue ext s tp
- ReadRef :: !(Atom s (ReferenceType tp)) -> AtomValue ext s tp
- NewRef :: !(Atom s tp) -> AtomValue ext s (ReferenceType tp)
- NewEmptyRef :: !(TypeRepr tp) -> AtomValue ext s (ReferenceType tp)
- FreshConstant :: !(BaseTypeRepr bt) -> !(Maybe SolverSymbol) -> AtomValue ext s (BaseToType bt)
- FreshFloat :: !(FloatInfoRepr fi) -> !(Maybe SolverSymbol) -> AtomValue ext s (FloatType fi)
- FreshNat :: !(Maybe SolverSymbol) -> AtomValue ext s NatType
- Call :: !(Atom s (FunctionHandleType args ret)) -> !(Assignment (Atom s) args) -> !(TypeRepr ret) -> AtomValue ext s ret
- type ValueSet s = Set (Some (Value s))
- exprType :: IsExpr e => e tp -> TypeRepr tp
- freshGlobalVar :: HandleAllocator -> Text -> TypeRepr tp -> IO (GlobalVar tp)
- cfgArgTypes :: CFG ext s init ret -> CtxRepr init
- cfgReturnType :: CFG ext s init ret -> TypeRepr ret
- cfgEntryBlock :: CFG ext s init ret -> Block ext s ret
- cfgInputTypes :: CFG ext s init ret -> CtxRepr init
- substCFG :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> CFG ext s init ret -> m (CFG ext s' init ret)
- substLabel :: Functor m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Label s -> m (Label s')
- substLambdaLabel :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> LambdaLabel s tp -> m (LambdaLabel s' tp)
- substBlockID :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> BlockID s -> m (BlockID s')
- substReg :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Reg s tp -> m (Reg s' tp)
- traverseCFG :: (Monad m, TraverseExt ext) => (genv -> penv -> Block ext s ret -> m (genv, penv)) -> genv -> penv -> Block ext s ret -> CFG ext s init ret -> m genv
- substAtom :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Atom s tp -> m (Atom s' tp)
- substAtomSource :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> AtomSource s tp -> m (AtomSource s' tp)
- mkInputAtoms :: forall m s init. Monad m => NonceGenerator m s -> Position -> CtxRepr init -> m (Assignment (Atom s) init)
- typeOfAtomValue :: (TypeApp (StmtExtension ext), TypeApp (ExprExtension ext)) => AtomValue ext s tp -> TypeRepr tp
- substAtomValue :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> AtomValue ext s tp -> m (AtomValue ext s' tp)
- typeOfValue :: Value s tp -> TypeRepr tp
- substValue :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Value s tp -> m (Value s' tp)
- substValueSet :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> ValueSet s -> m (ValueSet s')
- mkBlock :: forall ext s ret. TraverseExt ext => BlockID s -> ValueSet s -> Seq (Posd (Stmt ext s)) -> Posd (TermStmt s ret) -> Block ext s ret
- substBlock :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Block ext s ret -> m (Block ext s' ret)
- substStmt :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Stmt ext s -> m (Stmt ext s')
- substPosdStmt :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Posd (Stmt ext s) -> m (Posd (Stmt ext s'))
- mapStmtAtom :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Atom s x -> m (Atom s x)) -> Stmt ext s -> m (Stmt ext s)
- termStmtInputs :: TermStmt s ret -> ValueSet s
- termNextLabels :: TermStmt s ret -> Maybe [BlockID s]
- substTermStmt :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> TermStmt s ret -> m (TermStmt s' ret)
- substPosdTermStmt :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Posd (TermStmt s ret) -> m (Posd (TermStmt s' ret))
- foldStmtInputs :: TraverseExt ext => (forall x. Value s x -> b -> b) -> Stmt ext s -> b -> b
- substExpr :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Expr ext s tp -> m (Expr ext s' tp)
- earlyMergeLoops :: (TraverseExt ext, Monad m, Show (CFG ext s init ret)) => NonceGenerator m s -> CFG ext s init ret -> m (CFG ext s init ret)
Generator
data Generator ext s (t :: Type -> Type) (ret :: CrucibleType) m a Source #
A generator is used for constructing a CFG from a sequence of monadic actions.
The ext
parameter indicates the syntax extension.
The s
parameter is the phantom parameter for CFGs.
The t
parameter is the parameterized type that allows user-defined
state.
The ret
parameter is the return type of the CFG.
The m
parameter is a monad over which the generator is lifted
The a
parameter is the value returned by the monad.
Instances
Monad m => MonadState (t s) (Generator ext s t ret m) Source # | |
MonadTrans (Generator ext s t ret) Source # | |
Defined in Lang.Crucible.CFG.Generator | |
MonadFail m => MonadFail (Generator ext s t ret m) Source # | |
Defined in Lang.Crucible.CFG.Generator | |
MonadIO m => MonadIO (Generator ext s t ret m) Source # | |
Defined in Lang.Crucible.CFG.Generator | |
Applicative (Generator ext s t ret m) Source # | |
Defined in Lang.Crucible.CFG.Generator pure :: a -> Generator ext s t ret m a # (<*>) :: Generator ext s t ret m (a -> b) -> Generator ext s t ret m a -> Generator ext s t ret m b # liftA2 :: (a -> b -> c) -> Generator ext s t ret m a -> Generator ext s t ret m b -> Generator ext s t ret m c # (*>) :: Generator ext s t ret m a -> Generator ext s t ret m b -> Generator ext s t ret m b # (<*) :: Generator ext s t ret m a -> Generator ext s t ret m b -> Generator ext s t ret m a # | |
Functor (Generator ext s t ret m) Source # | |
Monad m => Monad (Generator ext s t ret m) Source # | |
MonadCatch m => MonadCatch (Generator ext s t ret m) Source # | |
Defined in Lang.Crucible.CFG.Generator | |
MonadThrow m => MonadThrow (Generator ext s t ret m) Source # | |
Defined in Lang.Crucible.CFG.Generator throwM :: (HasCallStack, Exception e) => e -> Generator ext s t ret m a # |
type FunctionDef ext t init ret m = forall s. Assignment (Atom s) init -> (t s, Generator ext s t ret m (Expr ext s ret)) Source #
Given the arguments, this returns the initial state, and an action for computing the return value.
:: (Monad m, IsSyntaxExtension ext) | |
=> Position | Source position for the function |
-> Some (NonceGenerator m) | Nonce generator for internal use |
-> FnHandle init ret | Handle for the generated function |
-> FunctionDef ext t init ret m | Generator action and initial state |
-> m (SomeCFG ext init ret, [AnyCFG ext]) | Generated CFG and inner function definitions |
The given FunctionDef
action is run to generate a registerized
CFG. The return value of defineFunction
is the generated CFG,
and a list of CFGs for any other auxiliary function definitions
generated along the way (e.g., for anonymous or inner functions).
This is the same as defineFunctionOpt
with the identity
transformation.
:: (Monad m, IsSyntaxExtension ext) | |
=> Position | Source position for the function |
-> Some (NonceGenerator m) | Nonce generator for internal use |
-> FnHandle init ret | Handle for the generated function |
-> FunctionDef ext t init ret m | Generator action and initial state |
-> (forall s. NonceGenerator m s -> CFG ext s init ret -> m (CFG ext s init ret)) | Transformation pass |
-> m (SomeCFG ext init ret, [AnyCFG ext]) | Generated CFG and inner function definitions |
The main API for generating CFGs for a Crucible function.
The given FunctionDef
action is run to generate a registerized
CFG. The return value of defineFunction
is the generated CFG,
and a list of CFGs for any other auxiliary function definitions
generated along the way (e.g., for anonymous or inner functions).
The caller can supply a transformation to run over the generated CFG (i.e. an optimization pass)
Positions
getPosition :: Generator ext s t ret m Position Source #
Get the current position.
setPosition :: Position -> Generator ext s t ret m () Source #
Set the current position.
withPosition :: Monad m => Position -> Generator ext s t ret m a -> Generator ext s t ret m a Source #
Set the current position temporarily, and reset it afterwards.
Expressions and statements
newReg :: (Monad m, IsSyntaxExtension ext) => Expr ext s tp -> Generator ext s t ret m (Reg s tp) Source #
Generate a new virtual register with the given initial value.
newUnassignedReg :: Monad m => TypeRepr tp -> Generator ext s t ret m (Reg s tp) Source #
Produce a new virtual register without giving it an initial value.
NOTE! If you fail to initialize this register with a subsequent
call to assignReg
, errors will arise during SSA conversion.
readReg :: (Monad m, IsSyntaxExtension ext) => Reg s tp -> Generator ext s t ret m (Expr ext s tp) Source #
Get the current value of a register.
assignReg :: (Monad m, IsSyntaxExtension ext) => Reg s tp -> Expr ext s tp -> Generator ext s t ret m () Source #
Update the value of a register.
modifyReg :: (Monad m, IsSyntaxExtension ext) => Reg s tp -> (Expr ext s tp -> Expr ext s tp) -> Generator ext s t ret m () Source #
Modify the value of a register.
modifyRegM :: (Monad m, IsSyntaxExtension ext) => Reg s tp -> (Expr ext s tp -> Generator ext s t ret m (Expr ext s tp)) -> Generator ext s t ret m () Source #
Modify the value of a register.
readGlobal :: (Monad m, IsSyntaxExtension ext) => GlobalVar tp -> Generator ext s t ret m (Expr ext s tp) Source #
Read a global variable.
writeGlobal :: (Monad m, IsSyntaxExtension ext) => GlobalVar tp -> Expr ext s tp -> Generator ext s t ret m () Source #
Write to a global variable.
References
newRef :: (Monad m, IsSyntaxExtension ext) => Expr ext s tp -> Generator ext s t ret m (Expr ext s (ReferenceType tp)) Source #
Generate a new reference cell with the given initial contents.
newEmptyRef :: (Monad m, IsSyntaxExtension ext) => TypeRepr tp -> Generator ext s t ret m (Expr ext s (ReferenceType tp)) Source #
Generate a new empty reference cell. If an unassigned reference is later read, it will generate a runtime error.
readRef :: (Monad m, IsSyntaxExtension ext) => Expr ext s (ReferenceType tp) -> Generator ext s t ret m (Expr ext s tp) Source #
Read the current value of a reference cell.
writeRef :: (Monad m, IsSyntaxExtension ext) => Expr ext s (ReferenceType tp) -> Expr ext s tp -> Generator ext s t ret m () Source #
Write the given value into the reference cell.
dropRef :: (Monad m, IsSyntaxExtension ext) => Expr ext s (ReferenceType tp) -> Generator ext s t ret m () Source #
Deallocate the given reference cell, returning it to an uninialized state. The reference cell can still be used; subsequent writes will succeed, and reads will succeed if some value is written first.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s (FunctionHandleType args ret) | function to call |
-> Assignment (Expr ext s) args | function arguments |
-> Generator ext s t r m (Expr ext s ret) |
Call a function.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s BoolType | assertion |
-> Expr ext s (StringType Unicode) | error message |
-> Generator ext s t ret m () |
Add an assert statement.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s BoolType | assumption |
-> Expr ext s (StringType Unicode) | reason message |
-> Generator ext s t ret m () |
Add an assume statement.
addPrintStmt :: (Monad m, IsSyntaxExtension ext) => Expr ext s (StringType Unicode) -> Generator ext s t ret m () Source #
Add a statement to print a value.
:: (Monad m, IsSyntaxExtension ext) | |
=> Text | breakpoint name |
-> Assignment (Value s) args | breakpoint values |
-> Generator ext s t r m () |
Add a breakpoint.
extensionStmt :: (Monad m, IsSyntaxExtension ext) => StmtExtension ext (Expr ext s) tp -> Generator ext s t ret m (Expr ext s tp) Source #
Add a statement from the syntax extension to the current basic block.
mkAtom :: (Monad m, IsSyntaxExtension ext) => Expr ext s tp -> Generator ext s t ret m (Atom s tp) Source #
Create an atom equivalent to the given expression if it is
not already an AtomExpr
.
mkFresh :: (Monad m, IsSyntaxExtension ext) => BaseTypeRepr tp -> Maybe SolverSymbol -> Generator ext s t ret m (Atom s (BaseToType tp)) Source #
mkFreshFloat :: (Monad m, IsSyntaxExtension ext) => FloatInfoRepr fi -> Maybe SolverSymbol -> Generator ext s t ret m (Atom s (FloatType fi)) Source #
forceEvaluation :: (Monad m, IsSyntaxExtension ext) => Expr ext s tp -> Generator ext s t ret m (Expr ext s tp) Source #
Evaluate an expression to an AtomExpr
, so that it can be reused multiple times later.
Labels
newLambdaLabel :: Monad m => KnownRepr TypeRepr tp => Generator ext s t ret m (LambdaLabel s tp) Source #
Create a new lambda label.
newLambdaLabel' :: Monad m => TypeRepr tp -> Generator ext s t ret m (LambdaLabel s tp) Source #
Create a new lambda label, using an explicit TypeRepr
.
currentBlockID :: Generator ext s t ret m (BlockID s) Source #
Return the label of the current basic block.
Block-terminating statements
The following operations produce block-terminating
statements, and have early termination behavior in the Generator
monad: Like fail
, they have polymorphic return types and cause
any following monadic actions to be skipped.
jump :: (Monad m, IsSyntaxExtension ext) => Label s -> Generator ext s t ret m a Source #
Jump to the given label.
jumpToLambda :: (Monad m, IsSyntaxExtension ext) => LambdaLabel s tp -> Expr ext s tp -> Generator ext s t ret m a Source #
Jump to the given label with output.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s BoolType | condition |
-> Label s | true label |
-> Label s | false label |
-> Generator ext s t ret m a |
Branch between blocks.
returnFromFunction :: (Monad m, IsSyntaxExtension ext) => Expr ext s ret -> Generator ext s t ret m a Source #
Return from this function with the given return value.
reportError :: (Monad m, IsSyntaxExtension ext) => Expr ext s (StringType Unicode) -> Generator ext s t ret m a Source #
Report an error message.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s (MaybeType tp) | |
-> LambdaLabel s tp | label for |
-> Label s | label for |
-> Generator ext s t ret m a |
Branch between blocks based on a Maybe
value.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s (VariantType varctx) | value to scrutinize |
-> Assignment (LambdaLabel s) varctx | target labels |
-> Generator ext s t ret m a |
Switch on a variant value. Examine the tag of the variant and jump to the appropriate switch target.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s (FunctionHandleType args ret) | function to call |
-> Assignment (Expr ext s) args | function arguments |
-> Generator ext s t ret m a |
End a block with a tail call to a function.
Defining blocks
The block-defining commands should be used with a
Generator
action ending with a block-terminating statement, which
gives it a polymorphic type.
defineBlock :: (Monad m, IsSyntaxExtension ext) => Label s -> (forall a. Generator ext s t ret m a) -> Generator ext s t ret m () Source #
Define a block with an ordinary label.
defineLambdaBlock :: (Monad m, IsSyntaxExtension ext) => LambdaLabel s tp -> (forall a. Expr ext s tp -> Generator ext s t ret m a) -> Generator ext s t ret m () Source #
Define a block that has a lambda label.
defineBlockLabel :: (Monad m, IsSyntaxExtension ext) => (forall a. Generator ext s t ret m a) -> Generator ext s t ret m (Label s) Source #
Define a block with a fresh label, returning the label.
recordCFG :: AnyCFG ext -> Generator ext s t ret m () Source #
Stash the given CFG away for later retrieval. This is primarily used when translating inner and anonymous functions in the context of an outer function.
Control-flow combinators
:: (Monad m, IsSyntaxExtension ext) | |
=> Label s | label for new block |
-> (forall a. Generator ext s t ret m a) | action to end current block |
-> Generator ext s t ret m () |
End the translation of the current block, and then continue generating a new block with the given label.
:: (Monad m, IsSyntaxExtension ext) | |
=> LambdaLabel s tp | label for new block |
-> (forall a. Generator ext s t ret m a) | action to end current block |
-> Generator ext s t ret m (Expr ext s tp) |
End the translation of the current block, and then continue generating a new lambda block with the given label. The return value is the argument to the lambda block.
whenCond :: (Monad m, IsSyntaxExtension ext) => Expr ext s BoolType -> Generator ext s t ret m () -> Generator ext s t ret m () Source #
Run a computation when a condition is true.
unlessCond :: (Monad m, IsSyntaxExtension ext) => Expr ext s BoolType -> Generator ext s t ret m () -> Generator ext s t ret m () Source #
Run a computation when a condition is false.
:: (Monad m, IsSyntaxExtension ext, KnownRepr TypeRepr tp) | |
=> Expr ext s BoolType | |
-> Generator ext s t ret m (Expr ext s tp) | true branch |
-> Generator ext s t ret m (Expr ext s tp) | false branch |
-> Generator ext s t ret m (Expr ext s tp) |
Expression-level if-then-else.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s BoolType | |
-> Generator ext s t ret m () | true branch |
-> Generator ext s t ret m () | false branch |
-> Generator ext s t ret m () |
Statement-level if-then-else.
:: (Monad m, IsSyntaxExtension ext, KnownRepr TypeRepr tp) | |
=> Generator ext s t ret m (Expr ext s BoolType) | |
-> Generator ext s t ret m (Expr ext s tp) | true branch |
-> Generator ext s t ret m (Expr ext s tp) | false branch |
-> Generator ext s t ret m (Expr ext s tp) |
Expression-level if-then-else with a monadic condition.
data MatchMaybe j r Source #
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s (MaybeType tp) | expression to scrutinize |
-> TypeRepr r | result type |
-> MatchMaybe (Expr ext s tp) (Generator ext s t ret m (Expr ext s r)) | case branches |
-> Generator ext s t ret m (Expr ext s r) |
Compute an expression by cases over a Maybe
value.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s (MaybeType tp) | expression to scrutinize |
-> MatchMaybe (Expr ext s tp) (Generator ext s t ret m ()) | case branches |
-> Generator ext s t ret m () |
Evaluate different statements by cases over a Maybe
value.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s (MaybeType tp) | |
-> Expr ext s (StringType Unicode) | error message |
-> Generator ext s t ret m (Expr ext s tp) |
Return the argument of a Just
value, or call reportError
if
the value is Nothing
.
:: (Monad m, IsSyntaxExtension ext) | |
=> Expr ext s (MaybeType tp) | |
-> Expr ext s (StringType Unicode) | error message |
-> Generator ext s t ret m (Expr ext s tp) |
This asserts that the value in the expression is a Just
value, and
returns the underlying value.
:: (Monad m, IsSyntaxExtension ext) | |
=> (Position, Generator ext s t ret m (Expr ext s BoolType)) | test condition |
-> (Position, Generator ext s t ret m ()) | loop body |
-> Generator ext s t ret m () |
Execute the loop body as long as the test condition is true.
Re-exports
Kind
comprises lists of types of kind Ctx
kk
.
Instances
FoldableFC (Assignment :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe foldMapFC :: forall f m. Monoid m => (forall (x :: k0). f x -> m) -> forall (x :: l). Assignment f x -> m # foldrFC :: (forall (x :: k0). f x -> b -> b) -> forall (x :: l). b -> Assignment f x -> b # foldlFC :: forall f b. (forall (x :: k0). b -> f x -> b) -> forall (x :: l). b -> Assignment f x -> b # foldrFC' :: (forall (x :: k0). f x -> b -> b) -> forall (x :: l). b -> Assignment f x -> b # foldlFC' :: forall f b. (forall (x :: k0). b -> f x -> b) -> forall (x :: l). b -> Assignment f x -> b # toListFC :: (forall (x :: k0). f x -> a) -> forall (x :: l). Assignment f x -> [a] # | |
FunctorFC (Assignment :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe fmapFC :: (forall (x :: k0). f x -> g x) -> forall (x :: l). Assignment f x -> Assignment g x # | |
OrdFC (Assignment :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe compareFC :: (forall (x :: k0) (y :: k0). f x -> f y -> OrderingF x y) -> forall (x :: l) (y :: l). Assignment f x -> Assignment f y -> OrderingF x y # | |
TestEqualityFC (Assignment :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe testEqualityFC :: (forall (x :: k0) (y :: k0). f x -> f y -> Maybe (x :~: y)) -> forall (x :: l) (y :: l). Assignment f x -> Assignment f y -> Maybe (x :~: y) # | |
TraversableFC (Assignment :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe traverseFC :: forall f g m. Applicative m => (forall (x :: k0). f x -> m (g x)) -> forall (x :: l). Assignment f x -> m (Assignment g x) # | |
FoldableFCWithIndex (Assignment :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe ifoldMapFC :: forall f m (z :: l). Monoid m => (forall (x :: k0). IndexF (Assignment f z) x -> f x -> m) -> Assignment f z -> m # ifoldrFC :: forall (z :: l) f b. (forall (x :: k0). IndexF (Assignment f z) x -> f x -> b -> b) -> b -> Assignment f z -> b # ifoldlFC :: forall f b (z :: l). (forall (x :: k0). IndexF (Assignment f z) x -> b -> f x -> b) -> b -> Assignment f z -> b # ifoldrFC' :: forall f b (z :: l). (forall (x :: k0). IndexF (Assignment f z) x -> f x -> b -> b) -> b -> Assignment f z -> b # ifoldlFC' :: forall f b. (forall (x :: k0). b -> f x -> b) -> forall (x :: l). b -> Assignment f x -> b # itoListFC :: forall f a (z :: l). (forall (x :: k0). IndexF (Assignment f z) x -> f x -> a) -> Assignment f z -> [a] # | |
FunctorFCWithIndex (Assignment :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe imapFC :: forall f g (z :: l). (forall (x :: k0). IndexF (Assignment f z) x -> f x -> g x) -> Assignment f z -> Assignment g z # | |
TraversableFCWithIndex (Assignment :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe itraverseFC :: forall m (z :: l) f g. Applicative m => (forall (x :: k0). IndexF (Assignment f z) x -> f x -> m (g x)) -> Assignment f z -> m (Assignment g z) # | |
OrdFC (BalancedTree h :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe | |
OrdFC (BinomialTree h :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe | |
TestEqualityFC (BalancedTree h :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe | |
TestEqualityFC (BinomialTree h :: (k -> Type) -> Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe | |
Category (Diff :: Ctx k -> Ctx k -> Type) | |
TestEquality (BlockID blocks :: Ctx CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.CFG.Core | |
TestEquality (MatlabFnWrapper t :: Ctx BaseType -> Type) | |
Defined in What4.Expr.Builder testEquality :: forall (a :: k) (b :: k). MatlabFnWrapper t a -> MatlabFnWrapper t b -> Maybe (a :~: b) # | |
IsSymFn (SymFn sym) => TestEquality (SymFnWrapper sym :: Ctx BaseType -> Type) | |
Defined in What4.Interface testEquality :: forall (a :: k) (b :: k). SymFnWrapper sym a -> SymFnWrapper sym b -> Maybe (a :~: b) # | |
TestEquality (CrucibleBranchTarget f :: Maybe (Ctx CrucibleType) -> Type) Source # | |
Defined in Lang.Crucible.Simulator.CallFrame testEquality :: forall (a :: k) (b :: k). CrucibleBranchTarget f a -> CrucibleBranchTarget f b -> Maybe (a :~: b) # | |
HashableF (MatlabFnWrapper t :: Ctx BaseType -> Type) | |
Defined in What4.Expr.Builder | |
OrdF (BlockID blocks :: Ctx CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.CFG.Core compareF :: forall (x :: k) (y :: k). BlockID blocks x -> BlockID blocks y -> OrderingF x y # leqF :: forall (x :: k) (y :: k). BlockID blocks x -> BlockID blocks y -> Bool # ltF :: forall (x :: k) (y :: k). BlockID blocks x -> BlockID blocks y -> Bool # geqF :: forall (x :: k) (y :: k). BlockID blocks x -> BlockID blocks y -> Bool # gtF :: forall (x :: k) (y :: k). BlockID blocks x -> BlockID blocks y -> Bool # | |
IsSymFn (SymFn sym) => OrdF (SymFnWrapper sym :: Ctx BaseType -> Type) | |
Defined in What4.Interface compareF :: forall (x :: k) (y :: k). SymFnWrapper sym x -> SymFnWrapper sym y -> OrderingF x y # leqF :: forall (x :: k) (y :: k). SymFnWrapper sym x -> SymFnWrapper sym y -> Bool # ltF :: forall (x :: k) (y :: k). SymFnWrapper sym x -> SymFnWrapper sym y -> Bool # geqF :: forall (x :: k) (y :: k). SymFnWrapper sym x -> SymFnWrapper sym y -> Bool # gtF :: forall (x :: k) (y :: k). SymFnWrapper sym x -> SymFnWrapper sym y -> Bool # | |
ShowF (BlockID blocks :: Ctx CrucibleType -> Type) Source # | |
ShowF (Size :: Ctx k -> Type) | |
TestEquality f => TestEquality (Assignment f :: Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe testEquality :: forall (a :: k0) (b :: k0). Assignment f a -> Assignment f b -> Maybe (a :~: b) # | |
(HashableF f, TestEquality f) => HashableF (Assignment f :: Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe hashWithSaltF :: forall (tp :: k0). Int -> Assignment f tp -> Int # hashF :: forall (tp :: k0). Assignment f tp -> Int # | |
OrdF f => OrdF (Assignment f :: Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe compareF :: forall (x :: k0) (y :: k0). Assignment f x -> Assignment f y -> OrderingF x y # leqF :: forall (x :: k0) (y :: k0). Assignment f x -> Assignment f y -> Bool # ltF :: forall (x :: k0) (y :: k0). Assignment f x -> Assignment f y -> Bool # geqF :: forall (x :: k0) (y :: k0). Assignment f x -> Assignment f y -> Bool # gtF :: forall (x :: k0) (y :: k0). Assignment f x -> Assignment f y -> Bool # | |
ShowF dom => ShowF (PointAbstraction blocks dom :: Ctx CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.Analysis.Fixpoint withShow :: forall p q (tp :: k) a. p (PointAbstraction blocks dom) -> q tp -> (Show (PointAbstraction blocks dom tp) => a) -> a # showF :: forall (tp :: k). PointAbstraction blocks dom tp -> String # showsPrecF :: forall (tp :: k). Int -> PointAbstraction blocks dom tp -> String -> String # | |
ShowF f => ShowF (Assignment f :: Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe withShow :: forall p q (tp :: k0) a. p (Assignment f) -> q tp -> (Show (Assignment f tp) => a) -> a # showF :: forall (tp :: k0). Assignment f tp -> String # showsPrecF :: forall (tp :: k0). Int -> Assignment f tp -> String -> String # | |
KnownRepr (Assignment f :: Ctx k -> Type) (EmptyCtx :: Ctx k) | |
Defined in Data.Parameterized.Context.Unsafe knownRepr :: Assignment f EmptyCtx # | |
(KnownRepr (Assignment f) ctx, KnownRepr f bt) => KnownRepr (Assignment f :: Ctx k -> Type) (ctx ::> bt :: Ctx k) | |
Defined in Data.Parameterized.Context.Unsafe knownRepr :: Assignment f (ctx ::> bt) # | |
HashableF f => HashableF (BalancedTree h f :: Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe | |
HashableF f => HashableF (BinomialTree h f :: Ctx k -> Type) | |
Defined in Data.Parameterized.Context.Unsafe | |
PrettyExt ext => ShowF (Block ext blocks ret :: Ctx CrucibleType -> Type) Source # | |
ShowF f => ShowF (BalancedTree h f :: Ctx k -> Type) | |
MonadState (SimState p sym ext rtp (OverrideLang ret) ('Just args)) (OverrideSim p sym ext rtp args ret) Source # | |
Defined in Lang.Crucible.Simulator.OverrideSim get :: OverrideSim p sym ext rtp args ret (SimState p sym ext rtp (OverrideLang ret) ('Just args)) # put :: SimState p sym ext rtp (OverrideLang ret) ('Just args) -> OverrideSim p sym ext rtp args ret () # state :: (SimState p sym ext rtp (OverrideLang ret) ('Just args) -> (a, SimState p sym ext rtp (OverrideLang ret) ('Just args))) -> OverrideSim p sym ext rtp args ret a # |
Instances
Show Position | |
NFData Position | |
Defined in What4.ProgramLoc | |
Eq Position | |
Ord Position | |
Defined in What4.ProgramLoc | |
Pretty Position | |
Defined in What4.ProgramLoc |
Statement in control flow graph.
forall tp. SetReg !(Reg s tp) !(Atom s tp) | |
forall tp. WriteGlobal !(GlobalVar tp) !(Atom s tp) | |
forall tp. WriteRef !(Atom s (ReferenceType tp)) !(Atom s tp) | |
forall tp. DropRef !(Atom s (ReferenceType tp)) | |
forall tp. DefineAtom !(Atom s tp) !(AtomValue ext s tp) | |
Print !(Atom s (StringType Unicode)) | |
Assert !(Atom s BoolType) !(Atom s (StringType Unicode)) | Assert that the given expression is true. |
Assume !(Atom s BoolType) !(Atom s (StringType Unicode)) | Assume the given expression. |
forall args. Breakpoint BreakpointName !(Assignment (Value s) args) |
data Value s (tp :: CrucibleType) Source #
A value is either a register or an atom.
Instances
TestEquality (Value s :: CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.CFG.Reg | |
OrdF (Value s :: CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.CFG.Reg compareF :: forall (x :: k) (y :: k). Value s x -> Value s y -> OrderingF x y # leqF :: forall (x :: k) (y :: k). Value s x -> Value s y -> Bool # ltF :: forall (x :: k) (y :: k). Value s x -> Value s y -> Bool # geqF :: forall (x :: k) (y :: k). Value s x -> Value s y -> Bool # gtF :: forall (x :: k) (y :: k). Value s x -> Value s y -> Bool # | |
ShowF (Value s :: CrucibleType -> Type) Source # | |
Pretty (ValueSet s) Source # | |
Defined in Lang.Crucible.CFG.Reg | |
Show (Value s tp) Source # | |
Pretty (Value s tp) Source # | |
Defined in Lang.Crucible.CFG.Reg |
data Atom s (tp :: CrucibleType) Source #
An expression in the control flow graph with a unique identifier. Unlike registers, atoms must be assigned exactly once.
Atom | |
|
Instances
TestEquality (Atom s :: CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.CFG.Reg | |
OrdF (Atom s :: CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.CFG.Reg compareF :: forall (x :: k) (y :: k). Atom s x -> Atom s y -> OrderingF x y # leqF :: forall (x :: k) (y :: k). Atom s x -> Atom s y -> Bool # ltF :: forall (x :: k) (y :: k). Atom s x -> Atom s y -> Bool # geqF :: forall (x :: k) (y :: k). Atom s x -> Atom s y -> Bool # gtF :: forall (x :: k) (y :: k). Atom s x -> Atom s y -> Bool # | |
Show (Atom s tp) Source # | |
Pretty (Atom s tp) Source # | |
Defined in Lang.Crucible.CFG.Reg |
A label for a block that does not expect an input.
data Expr ext s (tp :: CrucibleType) Source #
An expression in RTL representation.
The type arguments are:
ext
- the extensions currently in use (use
()
for no extension) s
- a dummy variable that should almost always be universally quantified
tp
- the Crucible type of the expression
App !(App ext (Expr ext s) tp) | An application of an expression |
AtomExpr !(Atom s tp) | An evaluated expession |
Instances
PrettyExt ext => ShowF (Expr ext s :: CrucibleType -> Type) Source # | |
TypeApp (ExprExtension ext) => IsExpr (Expr ext s) Source # | |
Defined in Lang.Crucible.CFG.Reg | |
IsString (Expr ext s (StringType Unicode)) Source # | |
Defined in Lang.Crucible.CFG.Reg fromString :: String -> Expr ext s (StringType Unicode) # | |
PrettyExt ext => Show (Expr ext s tp) Source # | |
PrettyExt ext => Pretty (Expr ext s tp) Source # | |
Defined in Lang.Crucible.CFG.Reg | |
type ExprExt (Expr ext s) Source # | |
Defined in Lang.Crucible.CFG.Reg |
data CFG ext s (init :: Ctx CrucibleType) (ret :: CrucibleType) Source #
A CFG using registers instead of SSA form.
Parameter ext
is the syntax extension, s
is a phantom type
parameter identifying a particular CFG, init
is the list of input
types of the CFG, and ret
is the return type.
data BlockID (s :: Type) where Source #
A label for a block is either a standard label, or a label expecting an input.
data GlobalVar (tp :: CrucibleType) Source #
A global variable.
GlobalVar | |
|
Instances
TestEquality GlobalVar Source # | |
Defined in Lang.Crucible.CFG.Common | |
OrdF GlobalVar Source # | |
Defined in Lang.Crucible.CFG.Common compareF :: forall (x :: k) (y :: k). GlobalVar x -> GlobalVar y -> OrderingF x y # leqF :: forall (x :: k) (y :: k). GlobalVar x -> GlobalVar y -> Bool # ltF :: forall (x :: k) (y :: k). GlobalVar x -> GlobalVar y -> Bool # geqF :: forall (x :: k) (y :: k). GlobalVar x -> GlobalVar y -> Bool # gtF :: forall (x :: k) (y :: k). GlobalVar x -> GlobalVar y -> Bool # | |
ShowF GlobalVar Source # | |
Show (GlobalVar tp) Source # | |
Pretty (GlobalVar tp) Source # | |
Defined in Lang.Crucible.CFG.Common |
newtype BreakpointName Source #
Instances
Show BreakpointName Source # | |
Defined in Lang.Crucible.CFG.Common showsPrec :: Int -> BreakpointName -> ShowS # show :: BreakpointName -> String # showList :: [BreakpointName] -> ShowS # | |
Eq BreakpointName Source # | |
Defined in Lang.Crucible.CFG.Common (==) :: BreakpointName -> BreakpointName -> Bool # (/=) :: BreakpointName -> BreakpointName -> Bool # | |
Ord BreakpointName Source # | |
Defined in Lang.Crucible.CFG.Common compare :: BreakpointName -> BreakpointName -> Ordering # (<) :: BreakpointName -> BreakpointName -> Bool # (<=) :: BreakpointName -> BreakpointName -> Bool # (>) :: BreakpointName -> BreakpointName -> Bool # (>=) :: BreakpointName -> BreakpointName -> Bool # max :: BreakpointName -> BreakpointName -> BreakpointName # min :: BreakpointName -> BreakpointName -> BreakpointName # | |
Pretty BreakpointName Source # | |
Defined in Lang.Crucible.CFG.Common pretty :: BreakpointName -> Doc ann # prettyList :: [BreakpointName] -> Doc ann # |
data Block ext s (ret :: CrucibleType) Source #
A basic block within a function.
Instances
PrettyExt ext => Show (Block ext s ret) Source # | |
Eq (Block ext s ret) Source # | |
Ord (Block ext s ret) Source # | |
Defined in Lang.Crucible.CFG.Reg compare :: Block ext s ret -> Block ext s ret -> Ordering # (<) :: Block ext s ret -> Block ext s ret -> Bool # (<=) :: Block ext s ret -> Block ext s ret -> Bool # (>) :: Block ext s ret -> Block ext s ret -> Bool # (>=) :: Block ext s ret -> Block ext s ret -> Bool # max :: Block ext s ret -> Block ext s ret -> Block ext s ret # min :: Block ext s ret -> Block ext s ret -> Block ext s ret # | |
PrettyExt ext => Pretty (Block ext s ret) Source # | |
Defined in Lang.Crucible.CFG.Reg |
data TermStmt s (ret :: CrucibleType) where Source #
Statement that terminates a basic block in a control flow graph.
Jump :: !(Label s) -> TermStmt s ret | |
Br :: !(Atom s BoolType) -> !(Label s) -> !(Label s) -> TermStmt s ret | |
MaybeBranch :: !(TypeRepr tp) -> !(Atom s (MaybeType tp)) -> !(LambdaLabel s tp) -> !(Label s) -> TermStmt s ret | |
VariantElim :: !(CtxRepr varctx) -> !(Atom s (VariantType varctx)) -> !(Assignment (LambdaLabel s) varctx) -> TermStmt s ret | |
Return :: !(Atom s ret) -> TermStmt s ret | |
TailCall :: !(Atom s (FunctionHandleType args ret)) -> !(CtxRepr args) -> !(Assignment (Atom s) args) -> TermStmt s ret | |
ErrorStmt :: !(Atom s (StringType Unicode)) -> TermStmt s ret | |
Output :: !(LambdaLabel s tp) -> !(Atom s tp) -> TermStmt s ret |
data Reg s (tp :: CrucibleType) Source #
A mutable value in the control flow graph.
Instances
TestEquality (Reg s :: CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.CFG.Reg | |
OrdF (Reg s :: CrucibleType -> Type) Source # | |
Defined in Lang.Crucible.CFG.Reg compareF :: forall (x :: k) (y :: k). Reg s x -> Reg s y -> OrderingF x y # leqF :: forall (x :: k) (y :: k). Reg s x -> Reg s y -> Bool # ltF :: forall (x :: k) (y :: k). Reg s x -> Reg s y -> Bool # geqF :: forall (x :: k) (y :: k). Reg s x -> Reg s y -> Bool # gtF :: forall (x :: k) (y :: k). Reg s x -> Reg s y -> Bool # | |
ShowF (Reg s :: CrucibleType -> Type) Source # | |
Show (Reg s tp) Source # | |
Pretty (Reg s tp) Source # | |
Defined in Lang.Crucible.CFG.Reg |
data LambdaLabel (s :: Type) (tp :: CrucibleType) Source #
A label for a block that expects an argument of a specific type.
LambdaLabel | |
|
Instances
data AtomSource s (tp :: CrucibleType) Source #
Identifies what generated an atom.
Assigned | |
FnInput | Input argument to function. They are ordered before other inputs to a program. |
LambdaArg !(LambdaLabel s tp) | Value passed into a lambda label. This must appear after other expressions. |
data AtomValue ext s (tp :: CrucibleType) where Source #
The value of an assigned atom.
EvalApp :: !(App ext (Atom s) tp) -> AtomValue ext s tp | |
ReadReg :: !(Reg s tp) -> AtomValue ext s tp | |
EvalExt :: !(StmtExtension ext (Atom s) tp) -> AtomValue ext s tp | |
ReadGlobal :: !(GlobalVar tp) -> AtomValue ext s tp | |
ReadRef :: !(Atom s (ReferenceType tp)) -> AtomValue ext s tp | |
NewRef :: !(Atom s tp) -> AtomValue ext s (ReferenceType tp) | |
NewEmptyRef :: !(TypeRepr tp) -> AtomValue ext s (ReferenceType tp) | |
FreshConstant :: !(BaseTypeRepr bt) -> !(Maybe SolverSymbol) -> AtomValue ext s (BaseToType bt) | |
FreshFloat :: !(FloatInfoRepr fi) -> !(Maybe SolverSymbol) -> AtomValue ext s (FloatType fi) | |
FreshNat :: !(Maybe SolverSymbol) -> AtomValue ext s NatType | |
Call :: !(Atom s (FunctionHandleType args ret)) -> !(Assignment (Atom s) args) -> !(TypeRepr ret) -> AtomValue ext s ret |
freshGlobalVar :: HandleAllocator -> Text -> TypeRepr tp -> IO (GlobalVar tp) Source #
cfgArgTypes :: CFG ext s init ret -> CtxRepr init Source #
cfgReturnType :: CFG ext s init ret -> TypeRepr ret Source #
cfgEntryBlock :: CFG ext s init ret -> Block ext s ret Source #
cfgInputTypes :: CFG ext s init ret -> CtxRepr init Source #
Deprecated: Use cfgArgTypes instead
substCFG :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> CFG ext s init ret -> m (CFG ext s' init ret) Source #
Rename all the atoms, labels, and other named things in the CFG. Useful for rewriting, since the names can be generated from a nonce generator the client controls (and can thus keep using to generate fresh names).
substLabel :: Functor m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Label s -> m (Label s') Source #
substLambdaLabel :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> LambdaLabel s tp -> m (LambdaLabel s' tp) Source #
substBlockID :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> BlockID s -> m (BlockID s') Source #
substReg :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Reg s tp -> m (Reg s' tp) Source #
traverseCFG :: (Monad m, TraverseExt ext) => (genv -> penv -> Block ext s ret -> m (genv, penv)) -> genv -> penv -> Block ext s ret -> CFG ext s init ret -> m genv Source #
Run a computation along all of the paths in a cfg, without taking backedges.
The computation has access to an environment that is specific to the current path being explored, as well as a global environment that is maintained across the entire computation.
substAtom :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Atom s tp -> m (Atom s' tp) Source #
substAtomSource :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> AtomSource s tp -> m (AtomSource s' tp) Source #
mkInputAtoms :: forall m s init. Monad m => NonceGenerator m s -> Position -> CtxRepr init -> m (Assignment (Atom s) init) Source #
typeOfAtomValue :: (TypeApp (StmtExtension ext), TypeApp (ExprExtension ext)) => AtomValue ext s tp -> TypeRepr tp Source #
substAtomValue :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> AtomValue ext s tp -> m (AtomValue ext s' tp) Source #
typeOfValue :: Value s tp -> TypeRepr tp Source #
substValue :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Value s tp -> m (Value s' tp) Source #
substValueSet :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> ValueSet s -> m (ValueSet s') Source #
substBlock :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Block ext s ret -> m (Block ext s' ret) Source #
substStmt :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Stmt ext s -> m (Stmt ext s') Source #
substPosdStmt :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Posd (Stmt ext s) -> m (Posd (Stmt ext s')) Source #
mapStmtAtom :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Atom s x -> m (Atom s x)) -> Stmt ext s -> m (Stmt ext s) Source #
termStmtInputs :: TermStmt s ret -> ValueSet s Source #
Returns the set of registers appearing as inputs to a terminal statement.
termNextLabels :: TermStmt s ret -> Maybe [BlockID s] Source #
Returns the next labels for the given block. Error statements
have no next labels, while return/tail call statements return Nothing
.
substTermStmt :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> TermStmt s ret -> m (TermStmt s' ret) Source #
substPosdTermStmt :: Applicative m => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Posd (TermStmt s ret) -> m (Posd (TermStmt s' ret)) Source #
foldStmtInputs :: TraverseExt ext => (forall x. Value s x -> b -> b) -> Stmt ext s -> b -> b Source #
Fold all registers that are inputs tostmt.
substExpr :: (Applicative m, TraverseExt ext) => (forall (x :: CrucibleType). Nonce s x -> m (Nonce s' x)) -> Expr ext s tp -> m (Expr ext s' tp) Source #
earlyMergeLoops :: (TraverseExt ext, Monad m, Show (CFG ext s init ret)) => NonceGenerator m s -> CFG ext s init ret -> m (CFG ext s init ret) Source #
This is the main pass that attempts to optimize early exits in the loops in a CFG. In particular, this transformation ensures that the postdominator of the loop header is a member of the loop.
Given a natural loop, its members are a set of blocks bs
. Let the exit edges be
the edges from some block b
in bs
to either the loop header or a block not in bs
.
Let (i, j) be such an exit edge.This transofrmation inserts a new
block r
such that in the transformed cfg there is an edge (i, r)
and an edge (r, j). Moreover, the transformation ensures that [i,
r, j'] is not feasible for j' != j. This works by setting a
"destination" register d := j
in each block i for each exit edge
(i, j), and switching on the value of d
in the block r
.