Jlm
Loading...
Searching...
No Matches
LambdaMemoryState.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
8
9namespace jlm::llvm
10{
11
12rvsdg::Output &
14{
15 JLM_ASSERT(is<llvm::LlvmLambdaOperation>(&lambdaNode));
16 const auto argument = lambdaNode.GetFunctionArguments().back();
17 JLM_ASSERT(is<MemoryStateType>(argument->Type()));
18 return *argument;
19}
20
23{
24 JLM_ASSERT(is<llvm::LlvmLambdaOperation>(&lambdaNode));
25 const auto result = lambdaNode.GetFunctionResults().back();
26 JLM_ASSERT(is<MemoryStateType>(result->Type()));
27 return *result;
28}
29
32{
33 auto & result = GetMemoryStateRegionResult(lambdaNode);
34
35 const auto node = rvsdg::TryGetOwnerNode<rvsdg::SimpleNode>(*result.origin());
36 return is<LambdaExitMemoryStateMergeOperation>(node) ? node : nullptr;
37}
38
41{
42 auto & argument = GetMemoryStateRegionArgument(lambdaNode);
43
44 // If a memory state entry split node is present, then we would expect the node to be the only
45 // user of the memory state argument.
46 if (argument.nusers() != 1)
47 return nullptr;
48
49 const auto node = rvsdg::TryGetOwnerNode<rvsdg::SimpleNode>(argument.SingleUser());
50 return is<LambdaEntryMemoryStateSplitOperation>(node) ? dynamic_cast<rvsdg::SimpleNode *>(node)
51 : nullptr;
52}
53
54}
#define JLM_ASSERT(x)
Definition common.hpp:16
Global memory state passed between functions.
rvsdg::SimpleNode * tryGetMemoryStateEntrySplit(const rvsdg::LambdaNode &lambdaNode) noexcept
rvsdg::Input & GetMemoryStateRegionResult(const rvsdg::LambdaNode &lambdaNode) noexcept
rvsdg::SimpleNode * tryGetMemoryStateExitMerge(const rvsdg::LambdaNode &lambdaNode) noexcept
rvsdg::Output & GetMemoryStateRegionArgument(const rvsdg::LambdaNode &lambdaNode) noexcept
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872