Jlm
Loading...
Searching...
No Matches
CallSummary.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 Nico Reißmann <nico.reissmann@gmail.com>
3 * Copyright 2025 Helge Bahmann <hcb@chaoticmind.net>
4 * See COPYING for terms of redistribution.
5 */
6
7#ifndef JLM_LLVM_CALL_SUMMARY_HPP
8#define JLM_LLVM_CALL_SUMMARY_HPP
9
13
14namespace jlm::llvm
15{
16
25class CallSummary final
26{
30
31public:
33 rvsdg::GraphExport * rvsdgExport,
34 std::vector<rvsdg::SimpleNode *> directCalls,
35 std::vector<rvsdg::Input *> otherUsers)
36 : RvsdgExport_(rvsdgExport),
37 DirectCalls_(std::move(directCalls)),
38 OtherUsers_(std::move(otherUsers))
39 {}
40
46 [[nodiscard]] bool
47 IsDead() const noexcept
48 {
49 return RvsdgExport_ == nullptr && DirectCalls_.empty() && OtherUsers_.empty();
50 }
51
57 [[nodiscard]] bool
58 IsExported() const noexcept
59 {
60 return RvsdgExport_ != nullptr;
61 }
62
68 [[nodiscard]] bool
69 IsOnlyExported() const noexcept
70 {
71 return RvsdgExport_ != nullptr && DirectCalls_.empty() && OtherUsers_.empty();
72 }
73
79 [[nodiscard]] bool
80 HasOnlyDirectCalls() const noexcept
81 {
82 return RvsdgExport_ == nullptr && OtherUsers_.empty() && !DirectCalls_.empty();
83 }
84
91 [[nodiscard]] bool
92 HasNoOtherUsages() const noexcept
93 {
94 return OtherUsers_.empty();
95 }
96
102 [[nodiscard]] bool
103 HasOnlyOtherUsages() const noexcept
104 {
105 return RvsdgExport_ == nullptr && DirectCalls_.empty() && !OtherUsers_.empty();
106 }
107
113 [[nodiscard]] size_t
114 NumDirectCalls() const noexcept
115 {
116 return DirectCalls_.size();
117 }
118
124 [[nodiscard]] size_t
125 NumOtherUsers() const noexcept
126 {
127 return OtherUsers_.size();
128 }
129
135 [[nodiscard]] rvsdg::GraphExport *
136 GetRvsdgExport() const noexcept
137 {
138 return RvsdgExport_;
139 }
140
146 [[nodiscard]] DirectCallsConstRange
147 DirectCalls() const noexcept
148 {
149 return { DirectCalls_.begin(), DirectCalls_.end() };
150 }
151
157 [[nodiscard]] OtherUsersConstRange
158 OtherUsers() const noexcept
159 {
160 return { OtherUsers_.begin(), OtherUsers_.end() };
161 }
162
174 static std::unique_ptr<CallSummary>
176 rvsdg::GraphExport * rvsdgExport,
177 std::vector<rvsdg::SimpleNode *> directCalls,
178 std::vector<rvsdg::Input *> otherUsers)
179 {
180 return std::make_unique<CallSummary>(
181 rvsdgExport,
182 std::move(directCalls),
183 std::move(otherUsers));
184 }
185
186private:
188 std::vector<rvsdg::SimpleNode *> DirectCalls_;
189 std::vector<rvsdg::Input *> OtherUsers_;
190};
191
193ComputeCallSummary(const rvsdg::LambdaNode & lambdaNode);
194
195}
196
197#endif
bool IsDead() const noexcept
size_t NumOtherUsers() const noexcept
rvsdg::GraphExport * RvsdgExport_
rvsdg::GraphExport * GetRvsdgExport() const noexcept
size_t NumDirectCalls() const noexcept
std::vector< rvsdg::SimpleNode * > DirectCalls_
util::IteratorRange< std::vector< rvsdg::SimpleNode * >::const_iterator > DirectCallsConstRange
bool IsOnlyExported() const noexcept
OtherUsersConstRange OtherUsers() const noexcept
DirectCallsConstRange DirectCalls() const noexcept
bool HasOnlyDirectCalls() const noexcept
bool HasOnlyOtherUsages() const noexcept
CallSummary(rvsdg::GraphExport *rvsdgExport, std::vector< rvsdg::SimpleNode * > directCalls, std::vector< rvsdg::Input * > otherUsers)
util::IteratorRange< std::vector< rvsdg::Input * >::const_iterator > OtherUsersConstRange
static std::unique_ptr< CallSummary > Create(rvsdg::GraphExport *rvsdgExport, std::vector< rvsdg::SimpleNode * > directCalls, std::vector< rvsdg::Input * > otherUsers)
std::vector< rvsdg::Input * > OtherUsers_
bool HasNoOtherUsages() const noexcept
bool IsExported() const noexcept
Global memory state passed between functions.
CallSummary ComputeCallSummary(const rvsdg::LambdaNode &lambdaNode)