Copyright | (c) 2019 Yann Herklotz |
---|---|
License | GPL-3 |
Maintainer | yann [at] yannherklotz [dot] com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Test case reducer implementation.
Synopsis
- reduceWithScript :: (MonadSh m, MonadIO m) => Text -> FilePath -> FilePath -> m ()
- reduceSynth :: (Synthesiser a, Synthesiser b, MonadSh m) => FilePath -> a -> b -> SourceInfo -> m SourceInfo
- reduceSynthesis :: (Synthesiser a, MonadSh m) => a -> SourceInfo -> m SourceInfo
- reduceSimIc :: (Synthesiser a, MonadSh m) => FilePath -> [ByteString] -> a -> SourceInfo -> m SourceInfo
- reduce :: MonadSh m => FilePath -> (SourceInfo -> m Bool) -> SourceInfo -> m SourceInfo
- reduce_ :: MonadSh m => FilePath -> Text -> Replace SourceInfo -> (SourceInfo -> Bool) -> (SourceInfo -> m Bool) -> SourceInfo -> m SourceInfo
- data Replacement a
- halveModules :: Replace SourceInfo
- halveModItems :: Identifier -> Replace SourceInfo
- halveStatements :: Identifier -> Replace SourceInfo
- halveExpr :: Identifier -> Replace SourceInfo
- halveAssigns :: Replace SourceInfo
- findActiveWires :: Identifier -> SourceInfo -> [Identifier]
- clean :: Mutate a => [Identifier] -> a -> a
- cleanSourceInfo :: Identifier -> SourceInfo -> SourceInfo
- cleanSourceInfoAll :: SourceInfo -> SourceInfo
- removeDecl :: SourceInfo -> SourceInfo
- removeConstInConcat :: Replace SourceInfo
- takeReplace :: Monoid a => Replacement a -> a
- filterExpr :: [Identifier] -> Expr -> Expr
Documentation
The reduction strategy has multiple different steps. reduce
will run these
strategies one after another, starting at the most coarse grained one. The
supported reduction strategies are the following:
- Modules
- First of all, the reducer will try and remove all the modules except the top module.
- Module Items
- Then, the module items will be reduced by using standard delta debugging. Half of the module items will be removed, and both versions will be tested. If both succeed, they will be divided further and tested further. Finally, the shortest version will be returned.
- Statements
- Once the module items have been reduced, the statements will be reduced as well. This is done using delta debugging, just like the module items.
- Expressions
- Finally, the expressions themselves will be reduced. This is done by splitting the top most binary expressions in half and testing each half.
reduceWithScript :: (MonadSh m, MonadIO m) => Text -> FilePath -> FilePath -> m () Source #
Reduce using a script that is passed to it
reduceSynth :: (Synthesiser a, Synthesiser b, MonadSh m) => FilePath -> a -> b -> SourceInfo -> m SourceInfo Source #
Reduce a SourceInfo
using two Synthesiser
that are passed to it.
reduceSynthesis :: (Synthesiser a, MonadSh m) => a -> SourceInfo -> m SourceInfo Source #
reduceSimIc :: (Synthesiser a, MonadSh m) => FilePath -> [ByteString] -> a -> SourceInfo -> m SourceInfo Source #
:: MonadSh m | |
=> FilePath | Filepath for temporary file. |
-> (SourceInfo -> m Bool) | Failed or not. |
-> SourceInfo | Input verilog source to be reduced. |
-> m SourceInfo | Reduced output. |
Reduce an input to a minimal representation. It follows the reduction strategy mentioned above.
reduce_ :: MonadSh m => FilePath -> Text -> Replace SourceInfo -> (SourceInfo -> Bool) -> (SourceInfo -> m Bool) -> SourceInfo -> m SourceInfo Source #
Reduction using custom reduction strategies.
data Replacement a Source #
Replacement type that supports returning different kinds of reduced replacements that could be tried.
Instances
halveModules :: Replace SourceInfo Source #
Removes half the modules randomly, until it reaches a minimal amount of modules. This is done by doing a binary search on the list of modules and removing the instantiations from the main module body.
halveModItems :: Identifier -> Replace SourceInfo Source #
Reducer for module items. It does a binary search on all the module items, except assignments to outputs and input-output declarations.
halveStatements :: Identifier -> Replace SourceInfo Source #
halveExpr :: Identifier -> Replace SourceInfo Source #
Reduce expressions by splitting them in half and keeping the half that succeeds.
halveAssigns :: Replace SourceInfo Source #
Split a module declaration in half by trying to remove assign statements. This is only done in the main module of the source.
findActiveWires :: Identifier -> SourceInfo -> [Identifier] Source #
clean :: Mutate a => [Identifier] -> a -> a Source #
cleanSourceInfo :: Identifier -> SourceInfo -> SourceInfo Source #
Clean a specific module. Have to be carful that the module is in the
SourceInfo
, otherwise it will crash.
removeDecl :: SourceInfo -> SourceInfo Source #
removeConstInConcat :: Replace SourceInfo Source #
takeReplace :: Monoid a => Replacement a -> a Source #
filterExpr :: [Identifier] -> Expr -> Expr Source #
Deletes Id Expr
if they are not part of the current scope, and replaces
these by 0.