Jlm
unary.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010 2011 2012 2014 Helge Bahmann <hcb@chaoticmind.net>
3  * Copyright 2011 2012 2013 2014 Nico Reißmann <nico.reissmann@gmail.com>
4  * See COPYING for terms of redistribution.
5  */
6 
7 #ifndef JLM_RVSDG_UNARY_HPP
8 #define JLM_RVSDG_UNARY_HPP
9 
10 #include <jlm/rvsdg/graph.hpp>
11 #include <jlm/rvsdg/node.hpp>
12 
13 #include <optional>
14 
15 namespace jlm::rvsdg
16 {
17 
18 typedef size_t unop_reduction_path_t;
19 
26 {
27 public:
28  ~UnaryOperation() noexcept override;
29 
31  std::shared_ptr<const jlm::rvsdg::Type> operand,
32  std::shared_ptr<const jlm::rvsdg::Type> result)
33  : SimpleOperation({ std::move(operand) }, { std::move(result) })
34  {}
35 
36  virtual unop_reduction_path_t
37  can_reduce_operand(const jlm::rvsdg::Output * arg) const noexcept = 0;
38 
39  virtual jlm::rvsdg::Output *
41 };
42 
44 /* operation is applied to constant, compute immediately */
46 /* operation does not change input operand */
48 /* operation is applied on inverse operation, can eliminate */
50 /* operation "supersedes" immediately preceding operation */
52 /* operation can be distributed into operands of preceding operation */
54 
67 std::optional<std::vector<rvsdg::Output *>>
69  const UnaryOperation & operation,
70  const std::vector<rvsdg::Output *> & operands);
71 
72 }
73 
74 #endif
const std::shared_ptr< const rvsdg::Type > & result(size_t index) const noexcept
Definition: operation.cpp:36
Unary operator.
Definition: unary.hpp:26
~UnaryOperation() noexcept override
Definition: unary.cpp:13
virtual jlm::rvsdg::Output * reduce_operand(unop_reduction_path_t path, jlm::rvsdg::Output *arg) const =0
UnaryOperation(std::shared_ptr< const jlm::rvsdg::Type > operand, std::shared_ptr< const jlm::rvsdg::Type > result)
Definition: unary.hpp:30
virtual unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *arg) const noexcept=0
size_t unop_reduction_path_t
Definition: unary.hpp:18
static const unop_reduction_path_t unop_reduction_inverse
Definition: unary.hpp:49
static const unop_reduction_path_t unop_reduction_idempotent
Definition: unary.hpp:47
static const unop_reduction_path_t unop_reduction_constant
Definition: unary.hpp:45
static const unop_reduction_path_t unop_reduction_narrow
Definition: unary.hpp:51
std::optional< std::vector< rvsdg::Output * > > NormalizeUnaryOperation(const UnaryOperation &operation, const std::vector< rvsdg::Output * > &operands)
Applies the reductions implemented in the unary operations reduction functions.
Definition: unary.cpp:17
static std::vector< jlm::rvsdg::Output * > operands(const Node *node)
Definition: node.hpp:1049
static const unop_reduction_path_t unop_reduction_none
Definition: unary.hpp:43
static const unop_reduction_path_t unop_reduction_distribute
Definition: unary.hpp:53