Jlm
TestOperations.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2025 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
7 
8 namespace jlm::rvsdg
9 {
10 
11 TestUnaryOperation::~TestUnaryOperation() noexcept = default;
12 
13 bool
14 TestUnaryOperation::operator==(const Operation & other) const noexcept
15 {
16  auto op = dynamic_cast<const TestUnaryOperation *>(&other);
17  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
18 }
19 
22 {
23  return unop_reduction_none;
24 }
25 
26 Output *
28 {
29  return nullptr;
30 }
31 
32 std::string
34 {
35  return "TestUnaryOperation";
36 }
37 
38 std::unique_ptr<Operation>
40 {
41  return std::make_unique<TestUnaryOperation>(*this);
42 }
43 
45 
46 bool
47 TestBinaryOperation::operator==(const Operation & other) const noexcept
48 {
49  auto op = dynamic_cast<const TestBinaryOperation *>(&other);
50  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
51 }
52 
55 {
56  return binop_reduction_none;
57 }
58 
59 Output *
61 {
62  return nullptr;
63 }
64 
66 TestBinaryOperation::flags() const noexcept
67 {
68  return flags_;
69 }
70 
71 std::string
73 {
74  return "TestBinaryOperation";
75 }
76 
77 std::unique_ptr<Operation>
79 {
80  return std::make_unique<TestBinaryOperation>(*this);
81 }
82 
83 TestOperation::~TestOperation() noexcept = default;
84 
85 bool
86 TestOperation::operator==(const Operation & other) const noexcept
87 {
88  const auto testOperation = dynamic_cast<const TestOperation *>(&other);
89  if (!testOperation)
90  return false;
91 
92  if (narguments() != testOperation->narguments() || nresults() != testOperation->nresults())
93  return false;
94 
95  for (size_t n = 0; n < narguments(); n++)
96  {
97  if (argument(n) != testOperation->argument(n))
98  return false;
99  }
100 
101  for (size_t n = 0; n < nresults(); n++)
102  {
103  if (result(n) != testOperation->result(n))
104  return false;
105  }
106 
107  return true;
108 }
109 
110 std::string
112 {
113  return "TestOperation";
114 }
115 
116 std::unique_ptr<Operation>
118 {
119  return std::make_unique<TestOperation>(*this);
120 }
121 
122 }
const std::shared_ptr< const rvsdg::Type > & argument(size_t index) const noexcept
Definition: operation.cpp:23
binop_reduction_path_t can_reduce_operand_pair(const Output *op1, const Output *op2) const noexcept override
~TestBinaryOperation() noexcept override
std::unique_ptr< Operation > copy() const override
enum BinaryOperation::flags flags_
Output * reduce_operand_pair(unop_reduction_path_t path, Output *op1, Output *op2) const override
enum BinaryOperation::flags flags() const noexcept override
std::string debug_string() const override
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
~TestOperation() noexcept override
~TestUnaryOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Output * reduce_operand(unop_reduction_path_t path, Output *operand) const override
std::string debug_string() const override
unop_reduction_path_t can_reduce_operand(const Output *operand) const noexcept override
size_t unop_reduction_path_t
Definition: unary.hpp:18
size_t binop_reduction_path_t
Definition: binary.hpp:19
static const unop_reduction_path_t unop_reduction_none
Definition: unary.hpp:43
static const binop_reduction_path_t binop_reduction_none
Definition: binary.hpp:203