7 #ifndef JLM_RVSDG_BINARY_HPP
8 #define JLM_RVSDG_BINARY_HPP
54 flags() const noexcept;
78 std::optional<std::vector<rvsdg::
Output *>>
95 std::optional<std::vector<rvsdg::
Output *>>
120 op_(std::unique_ptr<BinaryOperation>(
static_cast<BinaryOperation *
>(op.copy().release())))
126 operator==(
const Operation & other)
const noexcept
override;
128 [[nodiscard]] std::string
131 [[nodiscard]] std::unique_ptr<Operation>
132 copy()
const override;
143 const std::vector<jlm::rvsdg::Output *> &
operands)
const;
155 std::unique_ptr<BinaryOperation>
op_;
170 std::optional<std::vector<rvsdg::Output *>>
173 const std::vector<rvsdg::Output *> &
operands);
~BinaryOperation() noexcept override
bool is_commutative() const noexcept
bool is_associative() const noexcept
virtual jlm::rvsdg::Output * reduce_operand_pair(binop_reduction_path_t path, jlm::rvsdg::Output *op1, jlm::rvsdg::Output *op2) const =0
BinaryOperation(const std::vector< std::shared_ptr< const jlm::rvsdg::Type >> operands, std::shared_ptr< const jlm::rvsdg::Type > result)
virtual binop_reduction_path_t can_reduce_operand_pair(const jlm::rvsdg::Output *op1, const jlm::rvsdg::Output *op2) const noexcept=0
static void reduce(Graph *graph, const FlattenedBinaryOperation::reduction &reduction)
FlattenedBinaryOperation(const BinaryOperation &op, size_t narguments)
~FlattenedBinaryOperation() noexcept override
const BinaryOperation & bin_operation() const noexcept
std::unique_ptr< BinaryOperation > op_
Region & GetRootRegion() const noexcept
virtual bool operator==(const Operation &other) const noexcept=0
virtual std::string debug_string() const =0
virtual std::unique_ptr< Operation > copy() const =0
Represent acyclic RVSDG subgraphs.
const std::shared_ptr< const rvsdg::Type > & argument(size_t index) const noexcept
const std::shared_ptr< const rvsdg::Type > & result(size_t index) const noexcept
size_t narguments() const noexcept
static bool reduce(const ControlFlowGraph &cfg, const std::function< bool(llvm::ControlFlowGraphNode *, std::unordered_set< llvm::ControlFlowGraphNode * > &)> &f)
static const binop_reduction_path_t binop_reduction_lneutral
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 constexpr enum BinaryOperation::flags operator|(enum BinaryOperation::flags a, enum BinaryOperation::flags b)
static const binop_reduction_path_t binop_reduction_constants
static constexpr enum BinaryOperation::flags operator&(enum BinaryOperation::flags a, enum BinaryOperation::flags b)
size_t binop_reduction_path_t
static const binop_reduction_path_t binop_reduction_rfold
static std::vector< jlm::rvsdg::Output * > operands(const Node *node)
static const binop_reduction_path_t binop_reduction_factor
static const binop_reduction_path_t binop_reduction_rneutral
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.
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
static const binop_reduction_path_t binop_reduction_merge
static const binop_reduction_path_t binop_reduction_lfold