Jlm
Loading...
Searching...
No Matches
IOStateElimination.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2025 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
9
10namespace jlm::hls
11{
12
13void
15{
16 // FIXME: This method routes a lot of superfluous IO states into regions. It is unnecessary work,
17 // even though DNE + CNE eventually removes them again.
18
19 for (auto & node : region.Nodes())
20 {
21 // Handle innermost regions first
22 if (const auto structuralNode = dynamic_cast<rvsdg::StructuralNode *>(&node))
23 {
24 for (auto & subregion : structuralNode->Subregions())
26 }
27
28 // Ensure all IO state outputs become dead
29 for (auto & output : node.Outputs())
30 {
31 if (rvsdg::is<llvm::IOStateType>(output.Type()))
32 {
34 output.divert_users(&ioStateOperand);
35 }
36 }
37 }
38}
39
41
42void
44{
45 const auto & graph = module.Rvsdg();
46 const auto rootRegion = &graph.GetRootRegion();
47 if (rootRegion->numNodes() != 1)
48 {
49 throw std::logic_error("Root should have only one node now");
50 }
51
52 const auto lambdaNode =
53 dynamic_cast<const rvsdg::LambdaNode *>(rootRegion->Nodes().begin().ptr());
54 if (!lambdaNode)
55 {
56 throw std::logic_error("Node needs to be a lambda");
57 }
58
59 eliminateIOStates(
60 *lambdaNode->subregion(),
62}
63
64}
~IOStateElimination() noexcept override
static void eliminateIOStates(rvsdg::Region &region, rvsdg::Output &ioStateArgument)
static rvsdg::Output & getIOStateArgument(const rvsdg::LambdaNode &lambdaNode) noexcept
Definition lambda.cpp:67
Represent acyclic RVSDG subgraphs.
Definition region.hpp:213
NodeRange Nodes() noexcept
Definition region.hpp:375
Output & RouteToRegion(Output &output, Region &region)
Definition node.cpp:381
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872