//===-- ArrayExprOptimizer.h ----------------------------------------------===// // // The KLEE Symbolic Virtual Machine // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef KLEE_ARRAYEXPROPTIMIZER_H #define KLEE_ARRAYEXPROPTIMIZER_H #include #include #include #include #include #include #include "klee/Expr.h" #include "klee/util/Ref.h" namespace klee { enum ArrayOptimizationType { NONE, ALL, INDEX, VALUE }; using array2idx_ty = std::map>>; using mapIndexOptimizedExpr_ty = std::map, std::vector>>; class ExprOptimizer { private: std::unordered_map> cacheExprOptimized; std::unordered_set cacheExprUnapplicable; std::unordered_map> cacheReadExprOptimized; public: /// Returns the optimised version of e. /// @param e expression to optimise /// @param valueOnly XXX document /// @return optimised expression ref optimizeExpr(const ref &e, bool valueOnly); private: bool computeIndexes(array2idx_ty &arrays, const ref &e, mapIndexOptimizedExpr_ty &idx_valIdx) const; ref getSelectOptExpr( const ref &e, std::vector &reads, std::map> &readInfo, bool isSymbolic); ref buildConstantSelectExpr(const ref &index, std::vector &arrayValues, Expr::Width width, unsigned elementsInArray) const; ref buildMixedSelectExpr(const ReadExpr *re, std::vector> &arrayValues, Expr::Width width, unsigned elementsInArray) const; }; } // namespace klee #endif /* KLEE_ARRAYEXPROPTIMIZER_H */