-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge TestgenCompilerTarget into TestgenTarget.
- Loading branch information
Showing
47 changed files
with
362 additions
and
469 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "backends/p4tools/common/compiler/compiler_result.h" | ||
|
||
namespace P4Tools { | ||
|
||
const IR::P4Program &CompilerResult::getProgram() const { return program; } | ||
|
||
CompilerResult::CompilerResult(const IR::P4Program &program) : program(program) {} | ||
|
||
} // namespace P4Tools |
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,35 @@ | ||
#ifndef BACKENDS_P4TOOLS_COMMON_COMPILER_COMPILER_RESULT_H_ | ||
#define BACKENDS_P4TOOLS_COMMON_COMPILER_COMPILER_RESULT_H_ | ||
|
||
#include <functional> | ||
#include <optional> | ||
|
||
#include "ir/ir.h" | ||
#include "lib/castable.h" | ||
|
||
namespace P4Tools { | ||
|
||
/// An extensible result object which is returned by the CompilerTarget. | ||
/// In its simplest form, this holds the transformed P4 program after the front- and midend passes. | ||
class CompilerResult : public ICastable { | ||
private: | ||
/// The reference to the input P4 program, after it has been transformed by the compiler. | ||
std::reference_wrapper<const IR::P4Program> program; | ||
|
||
public: | ||
explicit CompilerResult(const IR::P4Program &program); | ||
|
||
/// @returns the reference to the input P4 program, after it has been transformed by the | ||
/// compiler. | ||
[[nodiscard]] const IR::P4Program &getProgram() const; | ||
|
||
DECLARE_TYPEINFO(CompilerResult); | ||
}; | ||
|
||
/// P4Tools compilers may return an error instead of a compiler result. | ||
/// This is a convenience definition for the return value. | ||
using CompilerResultOrError = std::optional<std::reference_wrapper<const CompilerResult>>; | ||
|
||
} // namespace P4Tools | ||
|
||
#endif /* BACKENDS_P4TOOLS_COMMON_COMPILER_COMPILER_RESULT_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
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,26 @@ | ||
#include "backends/p4tools/modules/testgen/core/compiler_result.h" | ||
|
||
#include <utility> | ||
|
||
#include "backends/p4tools/common/compiler/reachability.h" | ||
#include "midend/coverage.h" | ||
|
||
namespace P4Tools::P4Testgen { | ||
|
||
TestgenCompilerResult::TestgenCompilerResult(CompilerResult compilerResult, | ||
P4::Coverage::CoverageSet coverableNodes, | ||
const NodesCallGraph *callGraph) | ||
: CompilerResult(std::move(compilerResult)), | ||
coverableNodes(std::move(coverableNodes)), | ||
callGraph(callGraph) {} | ||
|
||
const NodesCallGraph &TestgenCompilerResult::getCallGraph() const { | ||
BUG_CHECK(callGraph != nullptr, "The call graph has not been initialized."); | ||
return *callGraph; | ||
} | ||
|
||
const P4::Coverage::CoverageSet &TestgenCompilerResult::getCoverableNodes() const { | ||
return coverableNodes; | ||
} | ||
|
||
} // namespace P4Tools::P4Testgen |
Oops, something went wrong.