Jlm
Loading...
Searching...
No Matches
ArithmeticWithOverflowIntrinsicOperations.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2026 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
7
8namespace jlm::llvm
9{
10
12
13bool
14SAddWithOverflowOperation::operator==(const Operation & other) const noexcept
15{
16 const auto operation = dynamic_cast<const SAddWithOverflowOperation *>(&other);
17 return operation && *operation->getOperandType() == *getOperandType();
18}
19
20std::string
22{
23 return util::strfmt("SAddWithOverflow[", getOperandType()->debug_string(), "]");
24}
25
26std::unique_ptr<rvsdg::Operation>
28{
29 return std::make_unique<SAddWithOverflowOperation>(*this);
30}
31
32void
33SAddWithOverflowOperation::checkOperandType(const std::shared_ptr<const rvsdg::Type> & type)
34{
35 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
36 {
37 throw std::runtime_error("SAddWithOverflowOperation::checkType: Expected integer type.");
38 }
39}
40
42
43bool
44UAddWithOverflowOperation::operator==(const Operation & other) const noexcept
45{
46 const auto operation = dynamic_cast<const UAddWithOverflowOperation *>(&other);
47 return operation && *operation->getOperandType() == *getOperandType();
48}
49
50std::string
52{
53 return util::strfmt("UAddWithOverflow[", getOperandType()->debug_string(), "]");
54}
55
56std::unique_ptr<rvsdg::Operation>
58{
59 return std::make_unique<UAddWithOverflowOperation>(*this);
60}
61
62void
63UAddWithOverflowOperation::checkOperandType(const std::shared_ptr<const rvsdg::Type> & type)
64{
65 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
66 {
67 throw std::runtime_error("UAddWithOverflowOperation::checkType: Expected integer type.");
68 }
69}
70
72
73bool
74SSubWithOverflowOperation::operator==(const Operation & other) const noexcept
75{
76 const auto operation = dynamic_cast<const SSubWithOverflowOperation *>(&other);
77 return operation && *operation->getOperandType() == *getOperandType();
78}
79
80std::string
82{
83 return util::strfmt("SSubWithOverflow[", getOperandType()->debug_string(), "]");
84}
85
86std::unique_ptr<rvsdg::Operation>
88{
89 return std::make_unique<SSubWithOverflowOperation>(*this);
90}
91
92void
93SSubWithOverflowOperation::checkOperandType(const std::shared_ptr<const rvsdg::Type> & type)
94{
95 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
96 {
97 throw std::runtime_error("SSubWithOverflowOperation::checkType: Expected integer type.");
98 }
99}
100
102
103bool
104SMulWithOverflowOperation::operator==(const Operation & other) const noexcept
105{
106 const auto operation = dynamic_cast<const SMulWithOverflowOperation *>(&other);
107 return operation && *operation->getOperandType() == *getOperandType();
108}
109
110std::string
112{
113 return util::strfmt("SMulWithOverflow[", getOperandType()->debug_string(), "]");
114}
115
116std::unique_ptr<rvsdg::Operation>
118{
119 return std::make_unique<SMulWithOverflowOperation>(*this);
120}
121
122void
123SMulWithOverflowOperation::checkOperandType(const std::shared_ptr<const rvsdg::Type> & type)
124{
125 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
126 {
127 throw std::runtime_error("SMulWithOverflowOperation::checkType: Expected integer type.");
128 }
129}
130
132
133bool
134UMulWithOverflowOperation::operator==(const Operation & other) const noexcept
135{
136 const auto operation = dynamic_cast<const UMulWithOverflowOperation *>(&other);
137 return operation && *operation->getOperandType() == *getOperandType();
138}
139
140std::string
142{
143 return util::strfmt("UMulWithOverflow[", getOperandType()->debug_string(), "]");
144}
145
146std::unique_ptr<rvsdg::Operation>
148{
149 return std::make_unique<UMulWithOverflowOperation>(*this);
150}
151
152void
153UMulWithOverflowOperation::checkOperandType(const std::shared_ptr<const rvsdg::Type> & type)
154{
155 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
156 {
157 throw std::runtime_error("UMulWithOverflowOperation::checkType: Expected integer type.");
158 }
159}
160
161}
static void checkOperandType(const std::shared_ptr< const rvsdg::Type > &type)
~SAddWithOverflowOperation() noexcept override
std::shared_ptr< const rvsdg::Type > getOperandType() const noexcept
std::unique_ptr< Operation > copy() const override
std::unique_ptr< Operation > copy() const override
std::shared_ptr< const rvsdg::Type > getOperandType() const noexcept
~SMulWithOverflowOperation() noexcept override
static void checkOperandType(const std::shared_ptr< const rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
~SSubWithOverflowOperation() noexcept override
static void checkOperandType(const std::shared_ptr< const rvsdg::Type > &type)
std::shared_ptr< const rvsdg::Type > getOperandType() const noexcept
static void checkOperandType(const std::shared_ptr< const rvsdg::Type > &type)
std::shared_ptr< const rvsdg::Type > getOperandType() const noexcept
~UAddWithOverflowOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::shared_ptr< const rvsdg::Type > getOperandType() const noexcept
static void checkOperandType(const std::shared_ptr< const rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
~UMulWithOverflowOperation() noexcept override
Global memory state passed between functions.
static std::string strfmt(Args... args)
Definition strfmt.hpp:35