Jlm
Loading...
Searching...
No Matches
FloatingPointMinMaxIntrinsicOperations.hpp
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
6#ifndef JLM_LLVM_IR_OPERATORS_FLOATINGPOINTMINMAXINTRINSICOPERATIONS_HPP
7#define JLM_LLVM_IR_OPERATORS_FLOATINGPOINTMINMAXINTRINSICOPERATIONS_HPP
8
9#include <jlm/llvm/ir/tac.hpp>
10#include <jlm/llvm/ir/types.hpp>
13
14namespace jlm::llvm
15{
16
24{
25public:
26 ~FloorOperation() noexcept override;
27
28 explicit FloorOperation(const std::shared_ptr<const rvsdg::Type> & type)
29 : UnaryOperation(type, type)
30 {
31 checkType(type);
32 }
33
34 bool
35 operator==(const Operation & other) const noexcept override;
36
37 std::string
38 debug_string() const override;
39
40 [[nodiscard]] std::unique_ptr<Operation>
41 copy() const override;
42
43 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
44 getType() const noexcept
45 {
46 return result(0);
47 }
48
49 static std::unique_ptr<ThreeAddressCode>
50 createTac(const Variable & operand)
51 {
52 auto operation = std::make_unique<FloorOperation>(operand.Type());
53 return ThreeAddressCode::create(std::move(operation), { &operand });
54 }
55
56 static rvsdg::SimpleNode &
58 {
59 return rvsdg::CreateOpNode<FloorOperation>({ &operand }, operand.Type());
60 }
61
62private:
63 static void
64 checkType(const std::shared_ptr<const rvsdg::Type> & type);
65};
66
74{
75public:
76 ~CeilOperation() noexcept override;
77
78 explicit CeilOperation(const std::shared_ptr<const rvsdg::Type> & type)
79 : UnaryOperation(type, type)
80 {
81 checkType(type);
82 }
83
84 bool
85 operator==(const Operation & other) const noexcept override;
86
87 std::string
88 debug_string() const override;
89
90 [[nodiscard]] std::unique_ptr<Operation>
91 copy() const override;
92
93 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
94 getType() const noexcept
95 {
96 return result(0);
97 }
98
99 static std::unique_ptr<ThreeAddressCode>
100 createTac(const Variable & operand)
101 {
102 auto operation = std::make_unique<CeilOperation>(operand.Type());
103 return ThreeAddressCode::create(std::move(operation), { &operand });
104 }
105
106 static rvsdg::SimpleNode &
108 {
109 return rvsdg::CreateOpNode<CeilOperation>({ &operand }, operand.Type());
110 }
111
112private:
113 static void
114 checkType(const std::shared_ptr<const rvsdg::Type> & type);
115};
116
124{
125public:
126 ~RoundOperation() noexcept override;
127
128 explicit RoundOperation(const std::shared_ptr<const rvsdg::Type> & type)
129 : UnaryOperation(type, type)
130 {
131 checkType(type);
132 }
133
134 bool
135 operator==(const Operation & other) const noexcept override;
136
137 std::string
138 debug_string() const override;
139
140 [[nodiscard]] std::unique_ptr<Operation>
141 copy() const override;
142
143 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
144 getType() const noexcept
145 {
146 return result(0);
147 }
148
149 static std::unique_ptr<ThreeAddressCode>
150 createTac(const Variable & operand)
151 {
152 auto operation = std::make_unique<RoundOperation>(operand.Type());
153 return ThreeAddressCode::create(std::move(operation), { &operand });
154 }
155
156 static rvsdg::SimpleNode &
158 {
159 return rvsdg::CreateOpNode<RoundOperation>({ &operand }, operand.Type());
160 }
161
162private:
163 static void
164 checkType(const std::shared_ptr<const rvsdg::Type> & type);
165};
166
174{
175public:
176 ~TruncIntrinsicOperation() noexcept override;
177
178 explicit TruncIntrinsicOperation(const std::shared_ptr<const rvsdg::Type> & type)
179 : UnaryOperation(type, type)
180 {
181 checkType(type);
182 }
183
184 bool
185 operator==(const Operation & other) const noexcept override;
186
187 std::string
188 debug_string() const override;
189
190 [[nodiscard]] std::unique_ptr<Operation>
191 copy() const override;
192
193 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
194 getType() const noexcept
195 {
196 return result(0);
197 }
198
199 static std::unique_ptr<ThreeAddressCode>
200 createTac(const Variable & operand)
201 {
202 auto operation = std::make_unique<TruncIntrinsicOperation>(operand.Type());
203 return ThreeAddressCode::create(std::move(operation), { &operand });
204 }
205
206 static rvsdg::SimpleNode &
208 {
209 return rvsdg::CreateOpNode<TruncIntrinsicOperation>({ &operand }, operand.Type());
210 }
211
212private:
213 static void
214 checkType(const std::shared_ptr<const rvsdg::Type> & type);
215};
216
224{
225public:
226 ~CopysignOperation() noexcept override;
227
228 explicit CopysignOperation(const std::shared_ptr<const rvsdg::Type> & type)
229 : SimpleOperation({ type, type }, { type })
230 {
231 checkType(type);
232 }
233
234 bool
235 operator==(const Operation & other) const noexcept override;
236
237 std::string
238 debug_string() const override;
239
240 [[nodiscard]] std::unique_ptr<Operation>
241 copy() const override;
242
243 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
244 getType() const noexcept
245 {
246 return result(0);
247 }
248
249 static std::unique_ptr<ThreeAddressCode>
250 createTac(const Variable & operand1, const Variable & operand2)
251 {
252 auto operation = std::make_unique<CopysignOperation>(operand1.Type());
253 return ThreeAddressCode::create(std::move(operation), { &operand1, &operand2 });
254 }
255
256 static rvsdg::SimpleNode &
257 createNode(rvsdg::Output & operand1, rvsdg::Output & operand2)
258 {
259 return rvsdg::CreateOpNode<CopysignOperation>({ &operand1, &operand2 }, operand1.Type());
260 }
261
262private:
263 static void
264 checkType(const std::shared_ptr<const rvsdg::Type> & type);
265};
266
274{
275public:
276 ~RIntOperation() noexcept override;
277
278 explicit RIntOperation(const std::shared_ptr<const rvsdg::Type> & type)
279 : UnaryOperation(type, type)
280 {
281 checkType(type);
282 }
283
284 bool
285 operator==(const Operation & other) const noexcept override;
286
287 std::string
288 debug_string() const override;
289
290 [[nodiscard]] std::unique_ptr<Operation>
291 copy() const override;
292
293 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
294 getType() const noexcept
295 {
296 return result(0);
297 }
298
299 static std::unique_ptr<ThreeAddressCode>
300 createTac(const Variable & operand)
301 {
302 auto operation = std::make_unique<RIntOperation>(operand.Type());
303 return ThreeAddressCode::create(std::move(operation), { &operand });
304 }
305
306 static rvsdg::SimpleNode &
308 {
309 return rvsdg::CreateOpNode<RIntOperation>({ &operand }, operand.Type());
310 }
311
312private:
313 static void
314 checkType(const std::shared_ptr<const rvsdg::Type> & type);
315};
316
317}
318
319#endif
std::unique_ptr< Operation > copy() const override
std::shared_ptr< const rvsdg::Type > getType() const noexcept
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
static std::unique_ptr< ThreeAddressCode > createTac(const Variable &operand)
static rvsdg::SimpleNode & createNode(rvsdg::Output &operand)
~CeilOperation() noexcept override
bool operator==(const Operation &other) const noexcept override
static rvsdg::SimpleNode & createNode(rvsdg::Output &operand1, rvsdg::Output &operand2)
~CopysignOperation() noexcept override
bool operator==(const Operation &other) const noexcept override
static std::unique_ptr< ThreeAddressCode > createTac(const Variable &operand1, const Variable &operand2)
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
std::shared_ptr< const rvsdg::Type > getType() const noexcept
static rvsdg::SimpleNode & createNode(rvsdg::Output &operand)
std::shared_ptr< const rvsdg::Type > getType() const noexcept
~FloorOperation() noexcept override
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< ThreeAddressCode > createTac(const Variable &operand)
bool operator==(const Operation &other) const noexcept override
~RIntOperation() noexcept override
static std::unique_ptr< ThreeAddressCode > createTac(const Variable &operand)
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
static rvsdg::SimpleNode & createNode(rvsdg::Output &operand)
std::shared_ptr< const rvsdg::Type > getType() const noexcept
std::unique_ptr< Operation > copy() const override
std::shared_ptr< const rvsdg::Type > getType() const noexcept
static rvsdg::SimpleNode & createNode(rvsdg::Output &operand)
std::unique_ptr< Operation > copy() const override
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
static std::unique_ptr< ThreeAddressCode > createTac(const Variable &operand)
bool operator==(const Operation &other) const noexcept override
~RoundOperation() noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(std::unique_ptr< rvsdg::SimpleOperation > operation, const std::vector< const Variable * > &operands)
Definition tac.hpp:135
~TruncIntrinsicOperation() noexcept override
static rvsdg::SimpleNode & createNode(rvsdg::Output &operand)
static std::unique_ptr< ThreeAddressCode > createTac(const Variable &operand)
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
bool operator==(const Operation &other) const noexcept override
const std::shared_ptr< const jlm::rvsdg::Type > Type() const noexcept
Definition variable.hpp:62
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
Definition node.hpp:366
const std::shared_ptr< const rvsdg::Type > & result(size_t index) const noexcept
Definition operation.cpp:36
SimpleOperation(std::vector< std::shared_ptr< const jlm::rvsdg::Type > > operands, std::vector< std::shared_ptr< const jlm::rvsdg::Type > > results)
Definition operation.hpp:61
Unary operator.
Definition unary.hpp:24
UnaryOperation(std::shared_ptr< const Type > operand, std::shared_ptr< const Type > result)
Definition unary.hpp:28
Global memory state passed between functions.
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872