Jlm
Loading...
Searching...
No Matches
bitoperation-classes.cpp
Go to the documentation of this file.
1/*
2 * Copyright 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
9#include <jlm/rvsdg/Trace.hpp>
10
11namespace jlm::rvsdg
12{
13
15
16std::optional<std::vector<Output *>>
17BitUnaryOperation::foldConstant(
18 const BitUnaryOperation & operation,
19 const std::vector<Output *> & operands)
20{
21 JLM_ASSERT(operands.size() == 1);
22
27 {
28 return std::vector({ &BitConstantOperation::create(
29 *constantNode->region(),
30 operation.reduce_constant(constantOperation->value())) });
31 }
32
33 return std::nullopt;
34}
35
37
52
76
77std::optional<std::vector<Output *>>
79 const BitBinaryOperation & operation,
80 const std::vector<Output *> & operands)
81{
82 JLM_ASSERT(operands.size() == 2);
83 auto & operand1 = *operands[0];
84 auto & operand2 = *operands[1];
85
90 {
91 return std::nullopt;
92 }
93
98 {
99 return std::nullopt;
100 }
101
103 *operand1.region(),
104 operation.reduce_constants(constantOperation1->value(), constantOperation2->value()));
105 return std::vector({ &result });
106}
107
109
112{
114}
115
116Output *
121
122std::optional<std::vector<Output *>>
124 const BitCompareOperation & operation,
125 const std::vector<Output *> & operands)
126{
127 JLM_ASSERT(operands.size() == 2);
128 auto & operand1 = *operands[0];
129 auto & operand2 = *operands[1];
130
134
138
141 : BitValueRepresentation::repeat(operation.type().nbits(), 'D');
144 : BitValueRepresentation::repeat(operation.type().nbits(), 'D');
145
147 {
149 return std::vector(
152 return std::vector(
154 default:
155 return std::nullopt;
156 }
157}
158
159}
~BitBinaryOperation() noexcept override
static std::optional< std::vector< Output * > > foldConstants(const BitBinaryOperation &operation, const std::vector< Output * > &operands)
virtual BitValueRepresentation reduce_constants(const BitValueRepresentation &arg1, const BitValueRepresentation &arg2) const =0
jlm::rvsdg::Output * reduce_operand_pair(binop_reduction_path_t path, jlm::rvsdg::Output *arg1, jlm::rvsdg::Output *arg2) const override
static std::optional< std::vector< Output * > > foldConstants(const BitCompareOperation &operation, const std::vector< Output * > &operands)
jlm::rvsdg::Output * reduce_operand_pair(binop_reduction_path_t path, jlm::rvsdg::Output *arg1, jlm::rvsdg::Output *arg2) const override
const BitType & type() const noexcept
virtual compare_result reduce_constants(const BitValueRepresentation &arg1, const BitValueRepresentation &arg2) const =0
~BitCompareOperation() noexcept override
static Output & create(Region &region, BitValueRepresentation value)
Definition constant.hpp:44
size_t nbits() const noexcept
Definition type.hpp:26
~BitUnaryOperation() noexcept override
static BitValueRepresentation repeat(size_t nbits, char bit)
const std::shared_ptr< const rvsdg::Type > & result(size_t index) const noexcept
Definition operation.cpp:36
#define JLM_ASSERT(x)
Definition common.hpp:16
static const binop_reduction_path_t binop_reduction_constants
Definition binary.hpp:205
static std::vector< jlm::rvsdg::Output * > operands(const Node *node)
Definition node.hpp:1049
size_t binop_reduction_path_t
Definition binary.hpp:19
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872
Output & traceOutputIntraProcedurally(Output &output)
Definition Trace.cpp:283
static const binop_reduction_path_t binop_reduction_none
Definition binary.hpp:203