Skip to content

Commit

Permalink
Add NormalizeFlattenedBinaryOperation normalization (phate#728)
Browse files Browse the repository at this point in the history
Co-authored-by: HKrogstie <[email protected]>
  • Loading branch information
phate and haved authored Jan 9, 2025
1 parent 00ac305 commit 72dc8ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions jlm/rvsdg/binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,14 @@ flattened_binary_op::reduce(
JLM_ASSERT(!Region::Contains<flattened_binary_op>(*region, true));
}

std::optional<std::vector<rvsdg::output *>>
NormalizeFlattenedBinaryOperation(
const flattened_binary_op & operation,
const std::vector<rvsdg::output *> & operands)
{
return NormalizeBinaryOperation(operation.bin_operation(), operands);
}

}

jlm::rvsdg::node_normal_form *
Expand Down
17 changes: 17 additions & 0 deletions jlm/rvsdg/binary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,23 @@ class flattened_binary_op final : public SimpleOperation
std::unique_ptr<BinaryOperation> op_;
};

/**
* \brief Applies the reductions of the binary operation represented by the flattened binary
* operation.
*
* @param operation The flattened binary operation on which the transformation is performed.
* @param operands The operands of the flattened binary node.
*
* @return If the normalization could be applied, then the results of the flattened binary operation
* after the transformation. Otherwise, std::nullopt.
*
* \see NormalizeBinaryOperation()
*/
std::optional<std::vector<rvsdg::output *>>
NormalizeFlattenedBinaryOperation(
const flattened_binary_op & operation,
const std::vector<rvsdg::output *> & operands);

/* binary flags operators */

static constexpr enum BinaryOperation::flags
Expand Down

0 comments on commit 72dc8ab

Please sign in to comment.