Jlm
arithmetic-impl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2024 Helge Bahmann <hcb@chaoticmind.net>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #ifndef JLM_RVSDG_BITSTRING_ARITHMETIC_IMPL_HPP
7 #define JLM_RVSDG_BITSTRING_ARITHMETIC_IMPL_HPP
8 
11 
12 namespace jlm::rvsdg
13 {
14 
15 template<typename reduction, const char * name>
17 {}
18 
19 template<typename reduction, const char * name>
20 bool
22 {
23  auto op = dynamic_cast<const MakeBitUnaryOperation *>(&other);
24  return op && op->type() == type();
25 }
26 
27 template<typename reduction, const char * name>
30 {
31  return reduction{}(arg);
32 }
33 
34 template<typename reduction, const char * name>
35 std::string
37 {
38  return jlm::util::strfmt(name, type().nbits());
39 }
40 
41 template<typename reduction, const char * name>
42 std::unique_ptr<Operation>
44 {
45  return std::make_unique<MakeBitUnaryOperation>(*this);
46 }
47 
48 template<typename reduction, const char * name>
49 std::unique_ptr<BitUnaryOperation>
51 {
52  return std::make_unique<MakeBitUnaryOperation>(nbits);
53 }
54 
55 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
57 {}
58 
59 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
60 bool
62 {
63  auto op = dynamic_cast<const MakeBitBinaryOperation *>(&other);
64  return op && op->type() == type();
65 }
66 
67 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
70  const BitValueRepresentation & arg1,
71  const BitValueRepresentation & arg2) const
72 {
73  return reduction{}(arg1, arg2);
74 }
75 
76 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
79 {
80  return opflags;
81 }
82 
83 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
84 std::string
86 {
87  return jlm::util::strfmt(name, type().nbits());
88 }
89 
90 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
91 std::unique_ptr<Operation>
93 {
94  return std::make_unique<MakeBitBinaryOperation>(*this);
95 }
96 
97 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
98 std::unique_ptr<BitBinaryOperation>
100 {
101  return std::make_unique<MakeBitBinaryOperation>(nbits);
102 }
103 
104 }
105 
106 #endif
const BitType & type() const noexcept
const BitType & type() const 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
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 std::string type(const Node *n)
Definition: view.cpp:255
static std::string strfmt(Args... args)
Definition: strfmt.hpp:35