Jlm
comparison-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_COMPARISON_IMPL_HPP
7 #define JLM_RVSDG_BITSTRING_COMPARISON_IMPL_HPP
8 
10 
11 namespace jlm::rvsdg
12 {
13 
14 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
16 {}
17 
18 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
19 bool
21  const Operation & other) const noexcept
22 {
23  auto op = dynamic_cast<const MakeBitComparisonOperation<reduction, name, opflags> *>(&other);
24  return op && op->type() == type();
25 }
26 
27 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
30  const BitValueRepresentation & arg1,
31  const BitValueRepresentation & arg2) const
32 {
33  switch (reduction()(arg1, arg2))
34  {
35  case '0':
37  case '1':
39  default:
41  }
42 }
43 
44 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
47 {
48  return opflags;
49 }
50 
51 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
52 std::string
54 {
55  return jlm::util::strfmt(name, type().nbits());
56 }
57 
58 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
59 std::unique_ptr<Operation>
61 {
62  return std::make_unique<MakeBitComparisonOperation>(*this);
63 }
64 
65 template<typename reduction, const char * name, enum BinaryOperation::flags opflags>
66 std::unique_ptr<BitCompareOperation>
68 {
69  return std::make_unique<MakeBitComparisonOperation>(nbits);
70 }
71 
72 }
73 
74 #endif
const BitType & type() const noexcept
enum BinaryOperation::flags flags() const noexcept override
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
static std::string type(const Node *n)
Definition: view.cpp:255
static std::string strfmt(Args... args)
Definition: strfmt.hpp:35