Jlm
Loading...
Searching...
No Matches
GeneralIntrinsicOperations.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
14IsConstantOperation::operator==(const Operation & other) const noexcept
15{
16 const auto operation = dynamic_cast<const IsConstantOperation *>(&other);
17 return operation && *operation->getType() == *getType();
18}
19
20std::string
22{
23 return util::strfmt("IsConstant[", getType()->debug_string(), "]");
24}
25
26std::unique_ptr<rvsdg::Operation>
28{
29 return std::make_unique<IsConstantOperation>(*this);
30}
31
32PtrMaskOperation::~PtrMaskOperation() noexcept = default;
33
34bool
35PtrMaskOperation::operator==(const Operation & other) const noexcept
36{
37 const auto operation = dynamic_cast<const PtrMaskOperation *>(&other);
38 return operation && *operation->getPtrOperandType() == *getPtrOperandType()
39 && *operation->getMaskOperandType() == *getMaskOperandType();
40}
41
42std::string
44{
45 return util::strfmt("PtrMask[", getMaskOperandType()->debug_string(), "]");
46}
47
48std::unique_ptr<rvsdg::Operation>
50{
51 return std::make_unique<PtrMaskOperation>(*this);
52}
53
54void
56 const std::shared_ptr<const rvsdg::Type> & ptrType,
57 const std::shared_ptr<const rvsdg::Type> & maskType)
58{
59 if (is<PointerType>(ptrType))
60 {
61 if (is<rvsdg::BitType>(maskType))
62 return;
63
64 throw std::runtime_error(
65 "PtrMaskOperation::checkOperandTypes: Expected mask type to be integer.");
66 }
67
68 if (const auto vectorType = std::dynamic_pointer_cast<const VectorType>(ptrType))
69 {
70 if (isVectorOfSize<const rvsdg::BitType>(*vectorType, vectorType->size()))
71 return;
72
73 throw std::runtime_error(util::strfmt(
74 "PtrMaskOperation::checkOperandTypes: Expected mask type to be a "
75 "vector of integers of size ",
76 vectorType->size(),
77 "."));
78 }
79
80 throw std::runtime_error(
81 "PtrMaskOperation::checkOperandTypes: Expected pointer or vector of pointer types.");
82}
83
84}
std::unique_ptr< Operation > copy() const override
~IsConstantOperation() noexcept override
std::shared_ptr< const rvsdg::Type > getType() const noexcept
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
std::shared_ptr< const rvsdg::Type > getPtrOperandType() const noexcept
static void checkOperandTypes(const std::shared_ptr< const rvsdg::Type > &ptrType, const std::shared_ptr< const rvsdg::Type > &maskType)
std::string debug_string() const override
std::shared_ptr< const rvsdg::Type > getMaskOperandType() const noexcept
~PtrMaskOperation() noexcept override
Global memory state passed between functions.
static std::string strfmt(Args... args)
Definition strfmt.hpp:35