Skip to content

Commit

Permalink
Add Specialize function to proc-state range query engine.
Browse files Browse the repository at this point in the history
This is used by some potential users and can be implemented better than the default do-nothing implementation.

Also fix a small typo.

PiperOrigin-RevId: 689129685
  • Loading branch information
allight authored and copybara-github committed Oct 23, 2024
1 parent e5d71a6 commit 2e896be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions xls/passes/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3420,6 +3420,7 @@ cc_library(
":back_propagate_range_analysis",
":dataflow_visitor",
":node_dependency_analysis",
":predicate_state",
":query_engine",
":range_query_engine",
":ternary_query_engine",
Expand Down
9 changes: 8 additions & 1 deletion xls/passes/proc_state_range_query_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <optional>
#include <utility>

#include "absl/container/flat_hash_set.h"
#include "absl/log/check.h"
#include "absl/status/statusor.h"
#include "absl/types/span.h"
Expand All @@ -30,6 +31,7 @@
#include "xls/ir/node.h"
#include "xls/ir/proc.h"
#include "xls/ir/ternary.h"
#include "xls/passes/predicate_state.h"
#include "xls/passes/query_engine.h"
#include "xls/passes/range_query_engine.h"
#include "xls/passes/ternary_query_engine.h"
Expand Down Expand Up @@ -81,7 +83,7 @@ class ProcStateRangeQueryEngine final : public QueryEngine {
}

bool AtLeastOneTrue(absl::Span<TreeBitLocation const> bits) const override {
return AtLeastOneTrue(bits);
return inner_.AtLeastOneTrue(bits);
}

bool KnownEquals(const TreeBitLocation& a,
Expand Down Expand Up @@ -136,6 +138,11 @@ class ProcStateRangeQueryEngine final : public QueryEngine {
return inner_.GetTernary(node);
}

std::unique_ptr<QueryEngine> SpecializeGivenPredicate(
const absl::flat_hash_set<PredicateState>& state) const override {
return inner_.SpecializeGivenPredicate(state);
}

private:
// Actual range results from the proc-state aware analysis.
std::unique_ptr<TernaryQueryEngine> ternary_;
Expand Down

0 comments on commit 2e896be

Please sign in to comment.