Jlm
comparison.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011 2012 2014 Nico Reißmann <nico.reissmann@gmail.com>
3  * Copyright 2014 2024 Helge Bahmann <hcb@chaoticmind.net>
4  * See COPYING for terms of redistribution.
5  */
6 
7 #ifndef JLM_RVSDG_BITSTRING_COMPARISON_HPP
8 #define JLM_RVSDG_BITSTRING_COMPARISON_HPP
9 
12 
13 namespace jlm::rvsdg
14 {
15 
16 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
18 {
19 public:
20  ~MakeBitComparisonOperation() noexcept override;
21 
22  explicit MakeBitComparisonOperation(std::size_t nbits) noexcept
24  {}
25 
26  bool
27  operator==(const Operation & other) const noexcept override;
28 
30  flags() const noexcept override;
31 
34  const override;
35 
36  std::string
37  debug_string() const override;
38 
39  [[nodiscard]] std::unique_ptr<Operation>
40  copy() const override;
41 
42  std::unique_ptr<BitCompareOperation>
43  create(size_t nbits) const override;
44 
45  static Output *
46  create(size_t nbits, Output * op1, Output * op2)
47  {
48  return CreateOpNode<MakeBitComparisonOperation>({ op1, op2 }, nbits).output(0);
49  }
50 };
51 
52 struct reduce_eq;
53 extern const char BitEqLabel[];
54 using biteq_op =
56 extern template class MakeBitComparisonOperation<
57  reduce_eq,
58  BitEqLabel,
60 
61 struct reduce_ne;
62 extern const char BitNeLabel[];
63 using bitne_op =
65 extern template class MakeBitComparisonOperation<
66  reduce_ne,
67  BitNeLabel,
69 
70 struct reduce_sge;
71 extern const char BitSgeLabel[];
73 extern template class MakeBitComparisonOperation<
74  reduce_sge,
77 
78 struct reduce_sgt;
79 extern const char BitSgtLabel[];
81 extern template class MakeBitComparisonOperation<
82  reduce_sgt,
85 
86 struct reduce_sle;
87 extern const char BitSleLabel[];
89 extern template class MakeBitComparisonOperation<
90  reduce_sle,
93 
94 struct reduce_slt;
95 extern const char BitSltLabel[];
97 extern template class MakeBitComparisonOperation<
98  reduce_slt,
101 
102 struct reduce_uge;
103 extern const char BitUgeLabel[];
105 extern template class MakeBitComparisonOperation<
106  reduce_uge,
107  BitUgeLabel,
109 
110 struct reduce_ugt;
111 extern const char BitUgtLabel[];
113 extern template class MakeBitComparisonOperation<
114  reduce_ugt,
115  BitUgtLabel,
117 
118 struct reduce_ule;
119 extern const char BitUleLabel[];
121 extern template class MakeBitComparisonOperation<
122  reduce_ule,
123  BitUleLabel,
125 
126 struct reduce_ult;
127 extern const char BitUltLabel[];
129 extern template class MakeBitComparisonOperation<
130  reduce_ult,
131  BitUltLabel,
133 
134 }
135 
136 #endif
BitCompareOperation(std::shared_ptr< const BitType > type) noexcept
static std::shared_ptr< const BitType > Create(std::size_t nbits)
Creates bit type of specified width.
Definition: type.cpp:45
enum BinaryOperation::flags flags() const noexcept override
MakeBitComparisonOperation(std::size_t nbits) noexcept
Definition: comparison.hpp:22
std::string debug_string() const override
compare_result reduce_constants(const BitValueRepresentation &arg1, const BitValueRepresentation &arg2) const override
std::unique_ptr< BitCompareOperation > create(size_t nbits) const override
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &other) const noexcept override
const char BitNeLabel[]
Definition: comparison.cpp:37
const char BitUleLabel[]
Definition: comparison.cpp:124
const char BitSleLabel[]
Definition: comparison.cpp:76
const char BitEqLabel[]
Definition: comparison.cpp:22
const char BitUgeLabel[]
Definition: comparison.cpp:100
const char BitSltLabel[]
Definition: comparison.cpp:88
const char BitUgtLabel[]
Definition: comparison.cpp:112
const char BitSgtLabel[]
Definition: comparison.cpp:64
const char BitSgeLabel[]
Definition: comparison.cpp:52
const char BitUltLabel[]
Definition: comparison.cpp:136