Jlm
Loading...
Searching...
No Matches
GeneralIntrinsicOperations.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_GENERALINTRINSICOPERATIONS_HPP
7#define JLM_LLVM_IR_OPERATORS_GENERALINTRINSICOPERATIONS_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 ~IsConstantOperation() noexcept override;
27
28 explicit IsConstantOperation(const std::shared_ptr<const rvsdg::Type> & type)
29 : UnaryOperation(type, rvsdg::BitType::Create(1))
30 {}
31
32 bool
33 operator==(const Operation & other) const noexcept override;
34
35 std::string
36 debug_string() const override;
37
38 [[nodiscard]] std::unique_ptr<Operation>
39 copy() const override;
40
41 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
42 getType() const noexcept
43 {
44 return result(0);
45 }
46
47 static std::unique_ptr<ThreeAddressCode>
48 createTac(const Variable & operand)
49 {
50 auto operation = std::make_unique<IsConstantOperation>(operand.Type());
51 return ThreeAddressCode::create(std::move(operation), { &operand });
52 }
53
54 static rvsdg::SimpleNode &
56 {
57 return rvsdg::CreateOpNode<IsConstantOperation>({ &operand }, operand.Type());
58 }
59};
60
68{
69public:
70 ~PtrMaskOperation() noexcept override;
71
73 const std::shared_ptr<const rvsdg::Type> & ptrOperandType,
74 const std::shared_ptr<const rvsdg::Type> & maskOperandType)
75 : SimpleOperation({ ptrOperandType, maskOperandType }, { ptrOperandType })
76 {}
77
78 bool
79 operator==(const Operation & other) const noexcept override;
80
81 std::string
82 debug_string() const override;
83
84 [[nodiscard]] std::unique_ptr<Operation>
85 copy() const override;
86
87 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
88 getPtrOperandType() const noexcept
89 {
90 return argument(0);
91 }
92
93 [[nodiscard]] std::shared_ptr<const rvsdg::Type>
94 getMaskOperandType() const noexcept
95 {
96 return argument(1);
97 }
98
99 static std::unique_ptr<ThreeAddressCode>
100 createTac(const Variable & ptrOperand, const Variable & maskOperand)
101 {
102 auto operation = std::make_unique<PtrMaskOperation>(ptrOperand.Type(), maskOperand.Type());
103 return ThreeAddressCode::create(std::move(operation), { &ptrOperand, &maskOperand });
104 }
105
106 static rvsdg::SimpleNode &
107 createNode(rvsdg::Output & ptrOperand, rvsdg::Output & maskOperand)
108 {
110 { &ptrOperand, &maskOperand },
111 ptrOperand.Type(),
112 maskOperand.Type());
113 }
114
115private:
116 static void
118 const std::shared_ptr<const rvsdg::Type> & ptrType,
119 const std::shared_ptr<const rvsdg::Type> & maskType);
120};
121
122}
123
124#endif
static rvsdg::SimpleNode & createNode(rvsdg::Output &operand)
bool operator==(const Operation &other) const noexcept override
static std::unique_ptr< ThreeAddressCode > createTac(const Variable &operand)
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)
static std::unique_ptr< ThreeAddressCode > createTac(const Variable &ptrOperand, const Variable &maskOperand)
static rvsdg::SimpleNode & createNode(rvsdg::Output &ptrOperand, rvsdg::Output &maskOperand)
std::string debug_string() const override
bool operator==(const Operation &other) const noexcept override
std::shared_ptr< const rvsdg::Type > getMaskOperandType() const noexcept
~PtrMaskOperation() 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
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 > & argument(size_t index) const noexcept
Definition operation.cpp:23
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