6 #include <gtest/gtest.h>
18 const std::shared_ptr<const jlm::rvsdg::Type> & operandType,
19 const std::shared_ptr<const jlm::rvsdg::Type> & resultType)
27 if (
const auto node = jlm::rvsdg::TryGetOwnerNode<jlm::rvsdg::SimpleNode>(*operand);
28 node && jlm::rvsdg::is<jlm::rvsdg::TestNullaryOperation>(node->GetOperation()))
54 [[nodiscard]] std::string
57 return "UnaryOperation";
60 [[nodiscard]] std::unique_ptr<Operation>
63 return std::make_unique<UnaryOperation>(this->
argument(0), this->
result(0));
67 TEST(ArgumentTests, NormalizeUnaryOperation_Success)
75 const auto nullaryNode = &CreateOpNode<TestNullaryOperation>(graph.
GetRootRegion(), valueType);
77 const auto unaryNode =
78 &CreateOpNode<::UnaryOperation>({ nullaryNode->output(0) }, valueType, valueType);
94 const auto node = TryGetOwnerNode<SimpleNode>(*ex.origin());
95 EXPECT_EQ(node, nullaryNode);
98 TEST(ArgumentTests, NormalizeUnaryOperation_Failure)
108 const auto unaryNode = &CreateOpNode<::UnaryOperation>({ i0 }, valueType, valueType);
119 EXPECT_FALSE(success);
124 const auto node = TryGetOwnerNode<SimpleNode>(*ex.origin());
125 EXPECT_EQ(node, unaryNode);
TEST(ArgumentTests, NormalizeUnaryOperation_Success)
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *operand) const noexcept override
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &) const noexcept override
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *operand) const override
UnaryOperation(const std::shared_ptr< const jlm::rvsdg::Type > &operandType, const std::shared_ptr< const jlm::rvsdg::Type > &resultType)
static GraphExport & Create(Output &origin, std::string name)
static GraphImport & Create(Graph &graph, std::shared_ptr< const rvsdg::Type > type, std::string name)
Region & GetRootRegion() const noexcept
size_t numNodes() const noexcept
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
static std::shared_ptr< const TestType > createValueType()
#define JLM_UNREACHABLE(msg)
size_t unop_reduction_path_t
static const unop_reduction_path_t unop_reduction_constant
std::string view(const rvsdg::Region *region)
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.
static const unop_reduction_path_t unop_reduction_none