Skip to content

Commit

Permalink
Replace boost::container::flat_map with a custom flat_map implementat…
Browse files Browse the repository at this point in the history
…ion in P4Tools.
  • Loading branch information
fruffy committed Jun 6, 2024
1 parent d5df09b commit 6cb483b
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 19 deletions.
1 change: 0 additions & 1 deletion backends/p4tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ cc_binary(
deps = [
":testgen_lib",
"//:lib",
"@boost//:filesystem",
"@boost//:multiprecision",
],
)
Expand Down
2 changes: 0 additions & 2 deletions backends/p4tools/common/lib/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <string>
#include <utility>

#include <boost/container/vector.hpp>

#include "frontends/p4/optimizeExpressions.h"
#include "ir/indexed_vector.h"
#include "ir/irutils.h"
Expand Down
7 changes: 4 additions & 3 deletions backends/p4tools/common/lib/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
#include <utility>
#include <vector>

#include <boost/container/flat_map.hpp>

#include "ir/ir.h"
#include "ir/solver.h"
#include "ir/visitor.h"
#include "lib/map.h"

namespace P4Tools {

/// Symbolic maps map a state variable to a IR::Expression.
using SymbolicMapType = boost::container::flat_map<IR::StateVariable, const IR::Expression *>;
using SymbolicMapType =
P4C::flat_map<IR::StateVariable, const IR::Expression *, std::less<IR::StateVariable>,
std::vector<std::pair<IR::StateVariable, const IR::Expression *>>>;

/// Represents a solution found by the solver. A model is a concretized form of a symbolic
/// environment. All the expressions in a Model must be of type IR::Literal.
Expand Down
2 changes: 0 additions & 2 deletions backends/p4tools/common/lib/symbolic_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <algorithm>
#include <utility>

#include <boost/container/vector.hpp>

#include "backends/p4tools/common/lib/model.h"
#include "ir/indexed_vector.h"
#include "ir/vector.h"
Expand Down
1 change: 0 additions & 1 deletion backends/p4tools/common/options.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef BACKENDS_P4TOOLS_COMMON_OPTIONS_H_
#define BACKENDS_P4TOOLS_COMMON_OPTIONS_H_

// Boost
#include <cstdint>
#include <optional>
#include <tuple>
Expand Down
1 change: 0 additions & 1 deletion backends/p4tools/modules/testgen/lib/execution_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <variant>
#include <vector>

#include <boost/container/vector.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include "backends/p4tools/common/compiler/convert_hs_index.h"
Expand Down
2 changes: 0 additions & 2 deletions backends/p4tools/modules/testgen/lib/final_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <variant>
#include <vector>

#include <boost/container/vector.hpp>

#include "backends/p4tools/common/lib/model.h"
#include "backends/p4tools/common/lib/symbolic_env.h"
#include "backends/p4tools/common/lib/trace_event.h"
Expand Down
11 changes: 4 additions & 7 deletions ir/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
#include <optional>
#include <vector>

#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>

#include "ir/ir.h"
#include "lib/castable.h"
#include "lib/cstring.h"
#include "lib/flat_map.h"

/// Represents a constraint that can be shipped to and asserted within a solver.
// TODO: This should implement AbstractRepCheckedNode<Constraint>.
Expand All @@ -23,10 +21,9 @@ struct SymbolicVarComp {
};

/// This type maps symbolic variables to their value assigned by the solver.
using SymbolicMapping = boost::container::flat_map<const IR::SymbolicVariable *,
const IR::Expression *, SymbolicVarComp>;

using SymbolicSet = boost::container::flat_set<const IR::SymbolicVariable *, SymbolicVarComp>;
using SymbolicMapping =
P4C::flat_map<const IR::SymbolicVariable *, const IR::Expression *, IR::SymbolicVariableLess,
std::vector<std::pair<const IR::SymbolicVariable *, const IR::Expression *>>>;

/// Provides a higher-level interface for an SMT solver.
class AbstractSolver : public ICastable {
Expand Down
Loading

0 comments on commit 6cb483b

Please sign in to comment.