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
20 changed files
with
461 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 @@ | ||
//===-- AlphaBuilder.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_BUILDER_H | ||
#define KLEE_ALPHA_BUILDER_H | ||
|
||
#include "klee/Expr/ArrayCache.h" | ||
#include "klee/Expr/ExprHashMap.h" | ||
#include "klee/Expr/ExprVisitor.h" | ||
|
||
namespace klee { | ||
|
||
class AlphaBuilder : 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: | ||
AlphaBuilder(ArrayCache &_arrayCache); | ||
constraints_ty visitConstraints(constraints_ty cs); | ||
ref<Expr> visitExpr(ref<Expr> v); | ||
}; | ||
|
||
} // namespace klee | ||
|
||
#endif /*KLEE_ALPHA_VERSION_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,84 @@ | ||
//===-- AlphaBuilder.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/AlphaBuilder.h" | ||
#include "klee/Expr/ArrayCache.h" | ||
#include "klee/Expr/SourceBuilder.h" | ||
|
||
#include <vector> | ||
|
||
namespace klee { | ||
|
||
const Array *AlphaBuilder::visitArray(const Array *arr) { | ||
if (alphaArrayMap.find(arr) == alphaArrayMap.end()) { | ||
ref<SymbolicSource> source = arr->source; | ||
ref<Expr> size = visit(arr->getSize()); | ||
|
||
if (!arr->isConstantArray()) { | ||
source = SourceBuilder::alpha(index); | ||
index++; | ||
alphaArrayMap[arr] = arrayCache.CreateArray( | ||
size, source, arr->getDomain(), arr->getRange()); | ||
reverseAlphaArrayMap[alphaArrayMap[arr]] = arr; | ||
} else if (size != arr->getSize()) { | ||
alphaArrayMap[arr] = arrayCache.CreateArray( | ||
size, source, arr->getDomain(), arr->getRange()); | ||
reverseAlphaArrayMap[alphaArrayMap[arr]] = arr; | ||
} else { | ||
alphaArrayMap[arr] = arr; | ||
reverseAlphaArrayMap[arr] = arr; | ||
} | ||
} | ||
return alphaArrayMap[arr]; | ||
} | ||
|
||
UpdateList AlphaBuilder::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 AlphaBuilder::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); | ||
} | ||
|
||
AlphaBuilder::AlphaBuilder(ArrayCache &_arrayCache) : arrayCache(_arrayCache) {} | ||
|
||
constraints_ty AlphaBuilder::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> AlphaBuilder::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.