25std::vector<jlm::rvsdg::Output *>
29 if (
op.is_commutative())
63std::optional<std::vector<rvsdg::Output *>>
66 const std::vector<rvsdg::Output *> &
operands)
107 std::make_unique<FlattenedBinaryOperation>(operation,
newOperands.size());
111std::optional<std::vector<rvsdg::Output *>>
114 const std::vector<rvsdg::Output *> &
operands)
117 auto region =
operands[0]->region();
152std::unique_ptr<Operation>
168 auto region =
operands.front()->region();
190 auto region =
operands.front()->region();
211 const std::vector<jlm::rvsdg::Output *> &
operands)
const
215 static std::unordered_map<
249 JLM_ASSERT(!Region::containsOperation<FlattenedBinaryOperation>(*region,
true));
252std::optional<std::vector<rvsdg::Output *>>
255 const std::vector<rvsdg::Output *> &
operands)
bool is_associative() const noexcept
~BinaryOperation() noexcept override
~FlattenedBinaryOperation() noexcept override
std::string debug_string() const override
jlm::rvsdg::Output * reduce(const FlattenedBinaryOperation::reduction &reduction, const std::vector< jlm::rvsdg::Output * > &operands) const
std::unique_ptr< BinaryOperation > op_
const BinaryOperation & bin_operation() const noexcept
std::unique_ptr< Operation > copy() const override
virtual std::unique_ptr< Operation > copy() const =0
void divert_users(jlm::rvsdg::Output *new_origin)
Represent acyclic RVSDG subgraphs.
static SimpleNode & Create(Region ®ion, std::unique_ptr< Operation > operation, const std::vector< rvsdg::Output * > &operands)
NodeOutput * output(size_t index) const noexcept
size_t narguments() const noexcept
Container pairwise_reduce(Container args, const Reductor &reductor)
std::vector< jlm::rvsdg::Output * > associative_flatten(std::vector< jlm::rvsdg::Output * > args, const FlattenTester &flatten_tester)
Container commutative_pairwise_reduce(Container args, const Reductor &reductor)
std::optional< std::vector< rvsdg::Output * > > NormalizeBinaryOperation(const BinaryOperation &operation, const std::vector< rvsdg::Output * > &operands)
Applies the reductions implemented in the binary operations reduction functions.
static void remove(Node *node)
static std::vector< jlm::rvsdg::Output * > operands(const Node *node)
static std::vector< jlm::rvsdg::Output * > outputs(const Node *node)
size_t binop_reduction_path_t
static jlm::rvsdg::Output * reduce_linear(const BinaryOperation &op, const std::vector< jlm::rvsdg::Output * > &operands)
std::optional< std::vector< rvsdg::Output * > > NormalizeFlattenedBinaryOperation(const FlattenedBinaryOperation &operation, const std::vector< rvsdg::Output * > &operands)
Applies the reductions of the binary operation represented by the flattened binary operation.
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
static jlm::rvsdg::Output * reduce_parallel(const BinaryOperation &op, const std::vector< jlm::rvsdg::Output * > &operands)
std::optional< std::vector< rvsdg::Output * > > FlattenAssociativeBinaryOperation(const BinaryOperation &operation, const std::vector< rvsdg::Output * > &operands)
Flattens a cascade of the same binary operations into a single flattened binary operation.
static const binop_reduction_path_t binop_reduction_none
detail::TopDownTraverserGeneric< false > TopDownTraverser
Traverser for visiting every node in a region in a top down order.
static std::string strfmt(Args... args)