Jlm
Loading...
Searching...
No Matches
arithmetic.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 2012 2014 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
6#ifndef JLM_RVSDG_BITSTRING_ARITHMETIC_HPP
7#define JLM_RVSDG_BITSTRING_ARITHMETIC_HPP
8
11
12namespace jlm::rvsdg
13{
14
15template<typename reduction, const char * name>
17{
18public:
19 ~MakeBitUnaryOperation() noexcept override;
20
21 explicit MakeBitUnaryOperation(std::size_t nbits) noexcept
23 {}
24
25 bool
26 operator==(const Operation & other) const noexcept override;
27
29 reduce_constant(const BitValueRepresentation & arg) const override;
30
31 std::string
32 debug_string() const override;
33
34 [[nodiscard]] std::unique_ptr<Operation>
35 copy() const override;
36
37 std::unique_ptr<BitUnaryOperation>
38 create(size_t nbits) const override;
39
40 static Output *
41 create(size_t nbits, Output * op)
42 {
43 return CreateOpNode<MakeBitUnaryOperation>({ op }, nbits).output(0);
44 }
45};
46
47template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
49{
50public:
51 ~MakeBitBinaryOperation() noexcept override;
52
53 explicit MakeBitBinaryOperation(std::size_t nbits) noexcept
55 {}
56
57 bool
58 operator==(const Operation & other) const noexcept override;
59
62
66
67 std::string
69
72
74 create(size_t nbits) const override;
75
77 create(size_t nbits, Output * op1, Output * op2)
78 {
79 return CreateOpNode<MakeBitBinaryOperation>({ op1, op2 }, nbits).output(0);
80 }
81};
82
83struct reduce_neg;
84extern const char BitNegateLabel[];
87
88struct reduce_not;
89extern const char BitNotLabel[];
92
93struct reduce_add;
94extern const char BitAddLabel[];
99extern template class MakeBitBinaryOperation<
103
104struct reduce_and;
105extern const char BitAndLabel[];
110extern template class MakeBitBinaryOperation<
114
115struct reduce_ashr;
116extern const char BitAShrLabel[];
118extern template class MakeBitBinaryOperation<
122
123struct reduce_mul;
124extern const char BitMulLabel[];
129extern template class MakeBitBinaryOperation<
133
134struct reduce_or;
135extern const char BitOrLabel[];
137 reduce_or,
140extern template class MakeBitBinaryOperation<
141 reduce_or,
144
145struct reduce_sdiv;
146extern const char BitSDivLabel[];
148extern template class MakeBitBinaryOperation<
152
153struct reduce_shl;
154extern const char BitShlLabel[];
157
158struct reduce_shr;
159extern const char BitShrLabel[];
162
163struct reduce_smod;
164extern const char BitSModLabel[];
166extern template class MakeBitBinaryOperation<
170
171struct reduce_smulh;
172extern const char BitSMulHLabel[];
175extern template class MakeBitBinaryOperation<
179
180struct reduce_sub;
181extern const char BitSubLabel[];
184
185struct reduce_udiv;
186extern const char BitUDivLabel[];
188extern template class MakeBitBinaryOperation<
192
193struct reduce_umod;
194extern const char BitUModLabel[];
196extern template class MakeBitBinaryOperation<
200
201struct reduce_umulh;
202extern const char BitUMulHLabel[];
205extern template class MakeBitBinaryOperation<
209
210struct reduce_xor;
211extern const char BitXorLabel[];
216extern template class MakeBitBinaryOperation<
220
221}
222
223#endif
static std::shared_ptr< const BitType > Create(std::size_t nbits)
Creates bit type of specified width.
Definition type.cpp:45
MakeBitBinaryOperation(std::size_t nbits) noexcept
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
bool operator==(const Operation &other) const noexcept override
~MakeBitBinaryOperation() noexcept override
BitValueRepresentation reduce_constants(const BitValueRepresentation &arg1, const BitValueRepresentation &arg2) const override
enum BinaryOperation::flags flags() const noexcept override
std::unique_ptr< BitBinaryOperation > create(size_t nbits) const override
~MakeBitUnaryOperation() noexcept override
MakeBitUnaryOperation(std::size_t nbits) noexcept
BitValueRepresentation reduce_constant(const BitValueRepresentation &arg) const override
std::unique_ptr< BitUnaryOperation > create(size_t nbits) const override
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
static Output * create(size_t nbits, Output *op)
const char BitOrLabel[]
const char BitNegateLabel[]
const char BitSMulHLabel[]
const char BitAndLabel[]
const char BitShrLabel[]
const char BitAShrLabel[]
const char BitSDivLabel[]
const char BitUDivLabel[]
const char BitShlLabel[]
const char BitUModLabel[]
const char BitNotLabel[]
const char BitMulLabel[]
const char BitXorLabel[]
const char BitUMulHLabel[]
const char BitSubLabel[]
const char BitAddLabel[]
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872
const char BitSModLabel[]