Jlm
Loading...
Searching...
No Matches
FloatingPointTestIntrinsicOperations.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
14IsFPClassOperation::operator==(const Operation & other) const noexcept
15{
16 const auto operation = dynamic_cast<const IsFPClassOperation *>(&other);
17 return operation && *operation->getType() == *getType();
18}
19
20std::string
22{
23 return util::strfmt("IsFPClass[", getType()->debug_string(), "]");
24}
25
26std::unique_ptr<rvsdg::Operation>
28{
29 return std::make_unique<IsFPClassOperation>(*this);
30}
31
32void
33IsFPClassOperation::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("IsFPClassOperation::checkType: Expected floating point type.");
38 }
39}
40
41std::shared_ptr<const rvsdg::Type>
42IsFPClassOperation::createResultType(const std::shared_ptr<const rvsdg::Type> & type)
43{
44 if (is<const FloatingPointType>(type))
45 return rvsdg::BitType::Create(1);
46
47 if (const auto fixedVectorType = std::dynamic_pointer_cast<const FixedVectorType>(type))
48 return FixedVectorType::Create(rvsdg::BitType::Create(1), fixedVectorType->size());
49
50 const auto scalableVectorType = std::dynamic_pointer_cast<const ScalableVectorType>(type);
51 return ScalableVectorType::Create(rvsdg::BitType::Create(1), scalableVectorType->size());
52}
53
54}
static std::shared_ptr< const FixedVectorType > Create(std::shared_ptr< const rvsdg::Type > type, size_t size)
Definition types.hpp:413
~IsFPClassOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static void checkType(const std::shared_ptr< const rvsdg::Type > &type)
static std::shared_ptr< const rvsdg::Type > createResultType(const std::shared_ptr< const rvsdg::Type > &type)
std::shared_ptr< const rvsdg::Type > getType() const noexcept
static std::shared_ptr< const ScalableVectorType > Create(std::shared_ptr< const rvsdg::Type > type, size_t size)
Definition types.hpp:438
static std::shared_ptr< const BitType > Create(std::size_t nbits)
Creates bit type of specified width.
Definition type.cpp:45
Global memory state passed between functions.
static std::string strfmt(Args... args)
Definition strfmt.hpp:35