forked from klee/klee
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
429 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//===-- AlphaVersionBuilder.h -----------------------------------*- C++ -*-===// | ||
// | ||
// The KLEE Symbolic Virtual Machine | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef KLEE_ALPHA_EQUIVALENCY_BUILDER_H | ||
#define KLEE_ALPHA_EQUIVALENCY_BUILDER_H | ||
|
||
#include "klee/Expr/ArrayCache.h" | ||
#include "klee/Expr/ExprHashMap.h" | ||
#include "klee/Expr/ExprVisitor.h" | ||
|
||
namespace klee { | ||
|
||
class AlphaVersionBuilder : public ExprVisitor { | ||
public: | ||
ExprHashMap<ref<Expr>> reverseExprMap; | ||
ArrayCache::ArrayHashMap<const Array *> reverseAlphaArrayMap; | ||
ArrayCache::ArrayHashMap<const Array *> alphaArrayMap; | ||
|
||
private: | ||
ArrayCache &arrayCache; | ||
unsigned index = 0; | ||
|
||
const Array *visitArray(const Array *arr); | ||
UpdateList visitUpdateList(UpdateList u); | ||
Action visitRead(const ReadExpr &re); | ||
|
||
public: | ||
AlphaVersionBuilder(ArrayCache &_arrayCache); | ||
constraints_ty visitConstraints(constraints_ty cs); | ||
ref<Expr> visitExpr(ref<Expr> v); | ||
}; | ||
|
||
} // namespace klee | ||
|
||
#endif /*KLEE_ALPHA_EQUIVALENCY_BUILDER_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//===-- AlphaVersionBuilder.cpp ---------------------------------*- C++ -*-===// | ||
// | ||
// The KLEE Symbolic Virtual Machine | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "klee/Expr/AlphaVersionBuilder.h" | ||
#include "klee/Expr/ArrayCache.h" | ||
#include "klee/Expr/SourceBuilder.h" | ||
|
||
#include <vector> | ||
|
||
namespace klee { | ||
|
||
const Array *AlphaVersionBuilder::visitArray(const Array *arr) { | ||
if (alphaArrayMap.find(arr) == alphaArrayMap.end()) { | ||
ref<SymbolicSource> source = arr->source; | ||
if (!arr->isConstantArray()) { | ||
source = SourceBuilder::alphaModulo(index); | ||
} | ||
ref<Expr> size = visit(arr->getSize()); | ||
alphaArrayMap[arr] = | ||
arrayCache.CreateArray(size, source, arr->getDomain(), arr->getRange()); | ||
reverseAlphaArrayMap[alphaArrayMap[arr]] = arr; | ||
index++; | ||
} | ||
return alphaArrayMap[arr]; | ||
} | ||
|
||
UpdateList AlphaVersionBuilder::visitUpdateList(UpdateList u) { | ||
const Array *root = visitArray(u.root); | ||
std::vector<ref<UpdateNode>> updates; | ||
|
||
for (auto un = u.head; un; un = un->next) { | ||
updates.push_back(un); | ||
} | ||
|
||
updates.push_back(nullptr); | ||
|
||
for (int i = updates.size() - 2; i >= 0; i--) { | ||
ref<Expr> index = visit(updates[i]->index); | ||
ref<Expr> value = visit(updates[i]->value); | ||
updates[i] = new UpdateNode(updates[i + 1], index, value); | ||
} | ||
return UpdateList(root, updates[0]); | ||
} | ||
|
||
ExprVisitor::Action AlphaVersionBuilder::visitRead(const ReadExpr &re) { | ||
ref<Expr> v = visit(re.index); | ||
UpdateList u = visitUpdateList(re.updates); | ||
ref<Expr> e = ReadExpr::create(u, v); | ||
return Action::changeTo(e); | ||
} | ||
|
||
AlphaVersionBuilder::AlphaVersionBuilder(ArrayCache &_arrayCache) | ||
: arrayCache(_arrayCache) {} | ||
|
||
constraints_ty AlphaVersionBuilder::visitConstraints(constraints_ty cs) { | ||
constraints_ty result; | ||
for (auto arg : cs) { | ||
ref<Expr> v = visit(arg); | ||
reverseExprMap[v] = arg; | ||
result.insert(v); | ||
} | ||
return result; | ||
} | ||
ref<Expr> AlphaVersionBuilder::visitExpr(ref<Expr> v) { | ||
ref<Expr> e = visit(v); | ||
reverseExprMap[e] = v; | ||
reverseExprMap[Expr::createIsZero(e)] = Expr::createIsZero(v); | ||
return e; | ||
} | ||
|
||
} // namespace klee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.