-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop'
- Loading branch information
Showing
39 changed files
with
44,775 additions
and
17 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
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,22 @@ | ||
#ifndef KLLVM_PROOF_TRACE_UTILS_CPP | ||
#define KLLVM_PROOF_TRACE_UTILS_CPP | ||
|
||
#include <kllvm/ast/AST.h> | ||
#include <kllvm/binary/ProofTraceParser.h> | ||
|
||
namespace kllvm { | ||
|
||
/* | ||
* This file contains utility functions that are used to pretty print | ||
* the Proof Trace and manipulate its data structures. | ||
*/ | ||
|
||
std::vector<int> parse_relative_location(std::string location); | ||
|
||
llvm_event *build_post_function_event( | ||
sptr<kore_composite_pattern> ¤t_config, | ||
sptr<llvm_function_event> &function_event, bool expand_terms); | ||
|
||
} // namespace kllvm | ||
|
||
#endif // KLLVM_PROOF_TRACE_UTILS_CPP |
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 @@ | ||
#include <kllvm/ast/AST.h> | ||
#include <kllvm/binary/ProofTraceUtils.h> | ||
|
||
using namespace kllvm; | ||
|
||
std::vector<int> kllvm::parse_relative_location(std::string location) { | ||
if (location.empty()) { | ||
return {}; | ||
} | ||
std::vector<int> positions; | ||
std::string delimiter = ":"; | ||
size_t pos = 0; | ||
std::string token; | ||
while ((pos = location.find(delimiter)) != std::string::npos) { | ||
token = location.substr(0, pos); | ||
positions.push_back(std::stoi(token)); | ||
location.erase(0, pos + delimiter.length()); | ||
} | ||
positions.push_back(std::stoi(location)); | ||
return positions; | ||
} | ||
|
||
llvm_event *kllvm::build_post_function_event( | ||
sptr<kore_composite_pattern> ¤t_config, | ||
sptr<llvm_function_event> &function_event, bool expand_terms) { | ||
sptr<kore_composite_pattern> new_config = nullptr; | ||
|
||
// The name of the function is actually the kore_symbol | ||
// corresponding to the function's constructor: function_name{...} | ||
// We need to extract only the function name to build the composite pattern | ||
auto function_name = function_event->get_name(); | ||
auto const *delimiter = "{"; | ||
auto pos = function_name.find(delimiter); | ||
if (pos != std::string::npos) { | ||
function_name = function_name.substr(0, pos); | ||
} | ||
|
||
// Construct the composite pattern for the function | ||
auto function = sptr<kore_composite_pattern>( | ||
kore_composite_pattern::create(function_name)); | ||
for (auto const &arg : function_event->get_arguments()) { | ||
function->add_argument(arg.getkore_pattern()); | ||
} | ||
|
||
// Construct location | ||
std::string location = function_event->get_relative_position(); | ||
std::vector<int> positions = kllvm::parse_relative_location(location); | ||
|
||
// We can only replace the argument and build a new configuration if we have a location | ||
// And it's a top level function. | ||
if (positions.size() == 1) { | ||
|
||
// Create a new configuration, set the ith argument to be replaced by the function or a pattern with it | ||
sptr<kore_composite_pattern> new_config | ||
= kore_composite_pattern::create(current_config->get_constructor()); | ||
int index = positions[0]; | ||
|
||
// Add the new pattern to the new configuration | ||
for (int i = 0; i < current_config->get_arguments().size(); i++) { | ||
auto argument | ||
= i == index ? function : current_config->get_arguments()[i]; | ||
new_config->add_argument(argument); | ||
} | ||
|
||
// Get new configuration size | ||
std::stringstream ss; | ||
new_config->print(ss); | ||
auto new_config_size = ss.str().size(); | ||
|
||
auto *new_config_event = new llvm_event(); | ||
new_config_event->setkore_pattern(new_config, new_config_size); | ||
|
||
return new_config_event; | ||
} | ||
|
||
return nullptr; | ||
} |
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,54 @@ | ||
version: 13 | ||
hook: MAP.element Lbl'UndsPipe'-'-GT-Unds'{} () | ||
arg: kore[\dv{SortKConfigVar{}}("$PGM")] | ||
arg: kore[\dv{SortString{}}("input_file")] | ||
hook result: kore[Lbl'UndsPipe'-'-GT-Unds'{}(\dv{SortKConfigVar{}}("$PGM"),\dv{SortString{}}("input_file"))] | ||
hook: MAP.unit Lbl'Stop'Map{} () | ||
hook result: kore[Lbl'Stop'Map{}()] | ||
hook: MAP.concat Lbl'Unds'Map'Unds'{} () | ||
arg: kore[Lbl'Stop'Map{}()] | ||
arg: kore[Lbl'UndsPipe'-'-GT-Unds'{}(\dv{SortKConfigVar{}}("$PGM"),\dv{SortString{}}("input_file"))] | ||
hook result: kore[Lbl'UndsPipe'-'-GT-Unds'{}(\dv{SortKConfigVar{}}("$PGM"),\dv{SortString{}}("input_file"))] | ||
function: LblinitGeneratedTopCell{} () | ||
arg: kore[Lbl'UndsPipe'-'-GT-Unds'{}(\dv{SortKConfigVar{}}("$PGM"),\dv{SortString{}}("input_file"))] | ||
rule: 2761 1 | ||
VarInit = kore[Lbl'UndsPipe'-'-GT-Unds'{}(\dv{SortKConfigVar{}}("$PGM"),\dv{SortString{}}("input_file"))] | ||
function: LblinitKCell{} (0) | ||
arg: kore[Lbl'UndsPipe'-'-GT-Unds'{}(\dv{SortKConfigVar{}}("$PGM"),\dv{SortString{}}("input_file"))] | ||
rule: 2762 1 | ||
VarInit = kore[Lbl'UndsPipe'-'-GT-Unds'{}(\dv{SortKConfigVar{}}("$PGM"),\dv{SortString{}}("input_file"))] | ||
hook: MAP.lookup LblMap'Coln'lookup{} (0:0:0:0:0) | ||
arg: kore[Lbl'UndsPipe'-'-GT-Unds'{}(\dv{SortKConfigVar{}}("$PGM"),\dv{SortString{}}("input_file"))] | ||
arg: kore[\dv{SortKConfigVar{}}("$PGM")] | ||
hook result: kore[\dv{SortString{}}("input_file")] | ||
function: Lblproject'Coln'String{} (0:0:0) | ||
arg: kore[kseq{}(\dv{SortString{}}("input_file"),dotk{}())] | ||
rule: 2841 1 | ||
VarK = kore[\dv{SortString{}}("input_file")] | ||
function: LblinitFdCell{} (1) | ||
rule: 2759 0 | ||
function: LblinitBufferCell{} (2) | ||
rule: 2758 0 | ||
function: LblinitGeneratedCounterCell{} (3) | ||
rule: 2760 0 | ||
config: kore[Lbl'-LT-'generatedTop'-GT-'{}(Lbl'-LT-'k'-GT-'{}(kseq{}(LblreadFromFile'LParUndsRParUnds'BUILTIN-IO'Unds'KItem'Unds'String{}(\dv{SortString{}}("input_file")),dotk{}())),Lbl'-LT-'fd'-GT-'{}(\dv{SortInt{}}("-1")),Lbl'-LT-'buffer'-GT-'{}(\dv{SortString{}}("")),Lbl'-LT-'generatedCounter'-GT-'{}(\dv{SortInt{}}("0")))] | ||
rule: 2712 4 | ||
Var'Unds'Gen0 = kore[Lbl'-LT-'fd'-GT-'{}(\dv{SortInt{}}("-1"))] | ||
Var'Unds'Gen1 = kore[Lbl'-LT-'buffer'-GT-'{}(\dv{SortString{}}(""))] | ||
Var'Unds'Gen2 = kore[Lbl'-LT-'generatedCounter'-GT-'{}(\dv{SortInt{}}("0"))] | ||
VarFILE = kore[\dv{SortString{}}("input_file")] | ||
function: Lbl'Hash'open'LParUndsRParUnds'K-IO'Unds'IOInt'Unds'String{} (0:0:0:0) | ||
arg: kore[\dv{SortString{}}("input_file")] | ||
rule: 2702 1 | ||
VarS = kore[\dv{SortString{}}("input_file")] | ||
hook: IO.open Lbl'Hash'open'LParUndsCommUndsRParUnds'K-IO'Unds'IOInt'Unds'String'Unds'String{} () | ||
arg: kore[\dv{SortString{}}("input_file")] | ||
arg: kore[\dv{SortString{}}("r+")] | ||
hook result: kore[Lbl'Hash'ENOENT{}()] | ||
config: kore[Lbl'-LT-'generatedTop'-GT-'{}(Lbl'-LT-'k'-GT-'{}(kseq{}(Lblopen'LParUndsRParUnds'BUILTIN-IO'Unds'KItem'Unds'IOInt{}(Lbl'Hash'ENOENT{}()),dotk{}())),Lbl'-LT-'fd'-GT-'{}(\dv{SortInt{}}("-1")),Lbl'-LT-'buffer'-GT-'{}(\dv{SortString{}}("")),Lbl'-LT-'generatedCounter'-GT-'{}(\dv{SortInt{}}("0")))] | ||
rule: 2710 4 | ||
Var'Unds'Gen0 = kore[\dv{SortInt{}}("-1")] | ||
Var'Unds'Gen1 = kore[Lbl'-LT-'buffer'-GT-'{}(\dv{SortString{}}(""))] | ||
Var'Unds'Gen2 = kore[Lbl'-LT-'generatedCounter'-GT-'{}(\dv{SortInt{}}("0"))] | ||
VarE = kore[Lbl'Hash'ENOENT{}()] | ||
config: kore[Lbl'-LT-'generatedTop'-GT-'{}(Lbl'-LT-'k'-GT-'{}(kseq{}(Lbl'Hash'ENOENT{}(),dotk{}())),Lbl'-LT-'fd'-GT-'{}(\dv{SortInt{}}("-2")),Lbl'-LT-'buffer'-GT-'{}(\dv{SortString{}}("")),Lbl'-LT-'generatedCounter'-GT-'{}(\dv{SortInt{}}("0")))] |
Oops, something went wrong.