Skip to content

Commit

Permalink
support aliased nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
esseivaju committed Sep 19, 2024
1 parent 87c16ce commit d1ffedb
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions src/orange/orangeinp/detail/DeMorganSimplifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,31 +109,45 @@ DeMorganSimplifierResult DeMorganSimplifier::operator()()
*/
void DeMorganSimplifier::find_join_negations()
{
auto handle_negated = [&](NodeId node_id, Negated const& negated) {
parents_[{negated.node, node_id}]
= parents_[{negated.node, has_parents_index_}] = true;
if (std::holds_alternative<Joined>(tree_[negated.node]))
{
// This is a negated join node
negated_join_nodes_[negated.node.get()] = true;
this->add_negation_for_operands(negated.node);
}
};
auto handle_joined = [&](NodeId node_id, Joined const& joined) {
for (auto const& join_operand : joined.nodes)
{
parents_[{join_operand, node_id}]
= parents_[{join_operand, has_parents_index_}] = true;
}
};
for (auto node_id : range(NodeId{tree_.size()}))
{
std::visit(
Overload{
[&](Negated const& negated) {
parents_[{negated.node, node_id}]
= parents_[{negated.node, has_parents_index_}] = true;
if (std::holds_alternative<Joined>(tree_[negated.node]))
handle_negated(node_id, negated);
},
[&](Joined const& joined) { handle_joined(node_id, joined); },
[&](Aliased const& aliased) {
auto const& alias_target = tree_[aliased.node];
// treat the aliased node as its target
if (std::holds_alternative<Negated>(alias_target))
{
// This is a negated join node
negated_join_nodes_[negated.node.get()] = true;
this->add_negation_for_operands(negated.node);
handle_negated(node_id,
std::get<Negated>(alias_target));
}
},
[&](Joined const& joined) {
for (auto const& join_operand : joined.nodes)
else if (std::holds_alternative<Joined>(alias_target))
{
parents_[{join_operand, node_id}]
= parents_[{join_operand, has_parents_index_}]
= true;
handle_joined(node_id, std::get<Joined>(alias_target));
}
},
[&](Aliased const&) {
// Not supported
CELER_ASSERT_UNREACHABLE();
CELER_EXPECT(
!std::holds_alternative<Aliased>(alias_target));
},
// Nothing to do for leaf node types
[](auto&&) {},
Expand Down

0 comments on commit d1ffedb

Please sign in to comment.