Jlm
Loading...
Searching...
No Matches
StdLibIntrinsicOperations.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2024 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
7
8namespace jlm::llvm
9{
10
12
13bool
14MemCpyNonVolatileOperation::operator==(const Operation & other) const noexcept
15{
16 auto operation = dynamic_cast<const MemCpyNonVolatileOperation *>(&other);
17 return operation && operation->LengthType() == LengthType()
18 && operation->NumMemoryStates() == NumMemoryStates();
19}
20
21std::string
23{
24 return "MemCpy";
25}
26
27std::unique_ptr<rvsdg::Operation>
29{
30 return std::make_unique<MemCpyNonVolatileOperation>(*this);
31}
32
33size_t
35{
36 return nresults();
37}
38
40
41bool
42MemCpyVolatileOperation::operator==(const Operation & other) const noexcept
43{
44 // Avoid common node elimination for memcpy operator
45 return this == &other;
46}
47
48std::string
50{
51 return "MemCpyVolatile";
52}
53
54std::unique_ptr<rvsdg::Operation>
56{
57 return std::make_unique<MemCpyVolatileOperation>(*this);
58}
59
60size_t
62{
63 // Subtracting I/O state
64 return nresults() - 1;
65}
66
68
69bool
70MemSetNonVolatileOperation::operator==(const Operation & other) const noexcept
71{
72 const auto operation = dynamic_cast<const MemSetNonVolatileOperation *>(&other);
73 return operation && operation->lengthType() == lengthType()
74 && operation->numMemoryStates() == numMemoryStates();
75}
76
77std::string
79{
80 return "MemSet";
81}
82
83std::unique_ptr<rvsdg::Operation>
85{
86 return std::make_unique<MemSetNonVolatileOperation>(*this);
87}
88
89size_t
91{
92 return nresults();
93}
94
96
97bool
98MemMoveNonVolatileOperation::operator==(const Operation & other) const noexcept
99{
100 const auto operation = dynamic_cast<const MemMoveNonVolatileOperation *>(&other);
101 return operation && operation->lengthType() == lengthType()
102 && operation->numMemoryStates() == numMemoryStates();
103}
104
105std::string
107{
108 return "MemMove";
109}
110
111std::unique_ptr<rvsdg::Operation>
113{
114 return std::make_unique<MemMoveNonVolatileOperation>(*this);
115}
116
117size_t
119{
120 return nresults();
121}
122
123UMaxOperation::~UMaxOperation() noexcept = default;
124
125bool
126UMaxOperation::operator==(const Operation & other) const noexcept
127{
128 const auto operation = dynamic_cast<const UMaxOperation *>(&other);
129 return operation && *operation->getType() == *getType();
130}
131
132std::string
134{
135 return util::strfmt("UMax[", getType()->debug_string(), "]");
136}
137
138std::unique_ptr<rvsdg::Operation>
140{
141 return std::make_unique<UMaxOperation>(*this);
142}
143
144void
145UMaxOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
146{
147 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
148 {
149 throw std::runtime_error("UMaxOperation::checkType: Expected integer type.");
150 }
151}
152
153SMinOperation::~SMinOperation() noexcept = default;
154
155bool
156SMinOperation::operator==(const Operation & other) const noexcept
157{
158 const auto operation = dynamic_cast<const SMinOperation *>(&other);
159 return operation && *operation->getType() == *getType();
160}
161
162std::string
164{
165 return util::strfmt("SMin[", getType()->debug_string(), "]");
166}
167
168std::unique_ptr<rvsdg::Operation>
170{
171 return std::make_unique<SMinOperation>(*this);
172}
173
174void
175SMinOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
176{
177 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
178 {
179 throw std::runtime_error("SMinOperation::checkType: Expected integer type.");
180 }
181}
182
183UMinOperation::~UMinOperation() noexcept = default;
184
185bool
186UMinOperation::operator==(const Operation & other) const noexcept
187{
188 const auto operation = dynamic_cast<const UMinOperation *>(&other);
189 return operation && *operation->getType() == *getType();
190}
191
192std::string
194{
195 return util::strfmt("UMin[", getType()->debug_string(), "]");
196}
197
198std::unique_ptr<rvsdg::Operation>
200{
201 return std::make_unique<UMinOperation>(*this);
202}
203
204void
205UMinOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
206{
207 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
208 {
209 throw std::runtime_error("UMinOperation::checkType: Expected integer type.");
210 }
211}
212
213FAbsOperation::~FAbsOperation() noexcept = default;
214
215bool
216FAbsOperation::operator==(const Operation & other) const noexcept
217{
218 const auto operation = dynamic_cast<const FAbsOperation *>(&other);
219 return operation && *operation->getType() == *getType();
220}
221
222std::string
224{
225 return util::strfmt("FAbs[", getType()->debug_string(), "]");
226}
227
228std::unique_ptr<rvsdg::Operation>
230{
231 return std::make_unique<FAbsOperation>(*this);
232}
233
234void
235FAbsOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
236{
237 if (!is<const FloatingPointType>(type) && !isVectorOf<const FloatingPointType>(*type))
238 {
239 throw std::runtime_error("FAbsOperation::checkType: Expected floating point type.");
240 }
241}
242
243AbsOperation::~AbsOperation() noexcept = default;
244
245bool
246AbsOperation::operator==(const Operation & other) const noexcept
247{
248 const auto operation = dynamic_cast<const AbsOperation *>(&other);
249 return operation && *operation->getType() == *getType();
250}
251
252std::string
254{
255 return util::strfmt("Abs[", getType()->debug_string(), "]");
256}
257
258std::unique_ptr<rvsdg::Operation>
260{
261 return std::make_unique<AbsOperation>(*this);
262}
263
264void
265AbsOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
266{
267 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
268 {
269 throw std::runtime_error("AbsOperation::checkType: Expected integer type.");
270 }
271}
272
273SMaxOperation::~SMaxOperation() noexcept = default;
274
275bool
276SMaxOperation::operator==(const Operation & other) const noexcept
277{
278 const auto operation = dynamic_cast<const SMaxOperation *>(&other);
279 return operation && *operation->getType() == *getType();
280}
281
282std::string
284{
285 return util::strfmt("SMax[", getType()->debug_string(), "]");
286}
287
288std::unique_ptr<rvsdg::Operation>
290{
291 return std::make_unique<SMaxOperation>(*this);
292}
293
294void
295SMaxOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
296{
297 if (!is<const rvsdg::BitType>(type) && !isVectorOf<const rvsdg::BitType>(*type))
298 {
299 throw std::runtime_error("SMaxOperation::checkType: Expected integer type.");
300 }
301}
302
303}
~AbsOperation() noexcept override
std::shared_ptr< const rvsdg::Type > getType() const noexcept
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
std::string debug_string() const override
~FAbsOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
std::shared_ptr< const rvsdg::Type > getType() const noexcept
std::unique_ptr< Operation > copy() const override
size_t NumMemoryStates() const noexcept override
bool operator==(const Operation &other) const noexcept override
const rvsdg::BitType & LengthType() const noexcept
std::unique_ptr< Operation > copy() const override
~MemCpyVolatileOperation() noexcept override
size_t NumMemoryStates() const noexcept override
size_t numMemoryStates() const noexcept override
std::unique_ptr< Operation > copy() const override
~MemMoveNonVolatileOperation() noexcept override
const rvsdg::BitType & lengthType() const noexcept
size_t numMemoryStates() const noexcept override
~MemSetNonVolatileOperation() noexcept override
std::unique_ptr< Operation > copy() const override
const rvsdg::BitType & lengthType() const noexcept
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
std::string debug_string() const override
~SMaxOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::shared_ptr< const rvsdg::Type > getType() const noexcept
~SMinOperation() noexcept override
std::string debug_string() const override
std::shared_ptr< const rvsdg::Type > getType() const noexcept
std::unique_ptr< Operation > copy() const override
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
std::shared_ptr< const rvsdg::Type > getType() const noexcept
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~UMaxOperation() noexcept override
std::unique_ptr< Operation > copy() const override
~UMinOperation() noexcept override
std::string debug_string() const override
std::shared_ptr< const rvsdg::Type > getType() const noexcept
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
size_t nresults() const noexcept
Definition operation.cpp:30
Global memory state passed between functions.
static std::string strfmt(Args... args)
Definition strfmt.hpp:35