Jlm
unary.cpp
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 #include <jlm/rvsdg/graph.hpp>
8 #include <jlm/rvsdg/unary.hpp>
9 
10 namespace jlm::rvsdg
11 {
12 
14 {}
15 
16 std::optional<std::vector<rvsdg::Output *>>
18  const UnaryOperation & operation,
19  const std::vector<rvsdg::Output *> & operands)
20 {
21  JLM_ASSERT(operands.size() == 1);
22  auto & operand = *operands[0];
23 
24  if (const auto reduction = operation.can_reduce_operand(&operand);
25  reduction != unop_reduction_none)
26  {
27  return { { operation.reduce_operand(reduction, &operand) } };
28  }
29 
30  return std::nullopt;
31 }
32 
33 }
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
virtual unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *arg) const noexcept=0
#define JLM_ASSERT(x)
Definition: common.hpp:16
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