Jlm
Loading...
Searching...
No Matches
FloatingPointMinMaxIntrinsicOperations.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
11FloorOperation::~FloorOperation() noexcept = default;
12
13bool
14FloorOperation::operator==(const Operation & other) const noexcept
15{
16 const auto operation = dynamic_cast<const FloorOperation *>(&other);
17 return operation && *operation->getType() == *getType();
18}
19
20std::string
22{
23 return util::strfmt("Floor[", getType()->debug_string(), "]");
24}
25
26std::unique_ptr<rvsdg::Operation>
28{
29 return std::make_unique<FloorOperation>(*this);
30}
31
32void
33FloorOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
34{
35 if (!is<const FloatingPointType>(type) && !isVectorOf<const FloatingPointType>(*type))
36 {
37 throw std::runtime_error("FloorOperation::checkType: Expected floating point type.");
38 }
39}
40
41CeilOperation::~CeilOperation() noexcept = default;
42
43bool
44CeilOperation::operator==(const Operation & other) const noexcept
45{
46 const auto operation = dynamic_cast<const CeilOperation *>(&other);
47 return operation && *operation->getType() == *getType();
48}
49
50std::string
52{
53 return util::strfmt("Ceil[", getType()->debug_string(), "]");
54}
55
56std::unique_ptr<rvsdg::Operation>
58{
59 return std::make_unique<CeilOperation>(*this);
60}
61
62void
63CeilOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
64{
65 if (!is<const FloatingPointType>(type) && !isVectorOf<const FloatingPointType>(*type))
66 {
67 throw std::runtime_error("CeilOperation::checkType: Expected floating point type.");
68 }
69}
70
71RoundOperation::~RoundOperation() noexcept = default;
72
73bool
74RoundOperation::operator==(const Operation & other) const noexcept
75{
76 const auto operation = dynamic_cast<const RoundOperation *>(&other);
77 return operation && *operation->getType() == *getType();
78}
79
80std::string
82{
83 return util::strfmt("Round[", getType()->debug_string(), "]");
84}
85
86std::unique_ptr<rvsdg::Operation>
88{
89 return std::make_unique<RoundOperation>(*this);
90}
91
92void
93RoundOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
94{
95 if (!is<const FloatingPointType>(type) && !isVectorOf<const FloatingPointType>(*type))
96 {
97 throw std::runtime_error("RoundOperation::checkType: Expected floating point type.");
98 }
99}
100
102
103bool
104TruncIntrinsicOperation::operator==(const Operation & other) const noexcept
105{
106 const auto operation = dynamic_cast<const TruncIntrinsicOperation *>(&other);
107 return operation && *operation->getType() == *getType();
108}
109
110std::string
112{
113 return util::strfmt("TruncIntrinsic[", getType()->debug_string(), "]");
114}
115
116std::unique_ptr<rvsdg::Operation>
118{
119 return std::make_unique<TruncIntrinsicOperation>(*this);
120}
121
122void
123TruncIntrinsicOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
124{
125 if (!is<const FloatingPointType>(type) && !isVectorOf<const FloatingPointType>(*type))
126 {
127 throw std::runtime_error("TruncIntrinsicOperation::checkType: Expected floating point type.");
128 }
129}
130
131CopysignOperation::~CopysignOperation() noexcept = default;
132
133bool
134CopysignOperation::operator==(const Operation & other) const noexcept
135{
136 const auto operation = dynamic_cast<const CopysignOperation *>(&other);
137 return operation && *operation->getType() == *getType();
138}
139
140std::string
142{
143 return util::strfmt("Copysign[", getType()->debug_string(), "]");
144}
145
146std::unique_ptr<rvsdg::Operation>
148{
149 return std::make_unique<CopysignOperation>(*this);
150}
151
152void
153CopysignOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
154{
155 if (!is<const FloatingPointType>(type) && !isVectorOf<const FloatingPointType>(*type))
156 {
157 throw std::runtime_error("CopysignOperation::checkType: Expected floating point type.");
158 }
159}
160
161RIntOperation::~RIntOperation() noexcept = default;
162
163bool
164RIntOperation::operator==(const Operation & other) const noexcept
165{
166 const auto operation = dynamic_cast<const RIntOperation *>(&other);
167 return operation && *operation->getType() == *getType();
168}
169
170std::string
172{
173 return util::strfmt("RInt[", getType()->debug_string(), "]");
174}
175
176std::unique_ptr<rvsdg::Operation>
178{
179 return std::make_unique<RIntOperation>(*this);
180}
181
182void
183RIntOperation::checkType(const std::shared_ptr<const rvsdg::Type> & type)
184{
185 if (!is<const FloatingPointType>(type) && !isVectorOf<const FloatingPointType>(*type))
186 {
187 throw std::runtime_error("RIntOperation::checkType: Expected floating point type.");
188 }
189}
190
191}
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)
~CeilOperation() noexcept override
~CopysignOperation() noexcept override
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
std::shared_ptr< const rvsdg::Type > getType() const noexcept
~FloorOperation() noexcept override
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
~RIntOperation() noexcept 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
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)
~RoundOperation() noexcept override
~TruncIntrinsicOperation() 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
Global memory state passed between functions.
static std::string strfmt(Args... args)
Definition strfmt.hpp:35