Jlm
Loading...
Searching...
No Matches
IOBarrierRemovalTests.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
6#include <gtest/gtest.h>
7
14
15TEST(IOBarrierRemovalTests, IOBarrierRemoval)
16{
17 using namespace jlm::hls;
18 using namespace jlm::llvm;
19 using namespace jlm::rvsdg;
20
21 // Arrange
22 auto i32Type = BitType::Create(32);
23 auto ioStateType = IOStateType::Create();
24 const auto functionType =
25 FunctionType::Create({ i32Type, i32Type, ioStateType }, { i32Type, ioStateType });
26
27 jlm::llvm::LlvmRvsdgModule rvsdgModule(jlm::util::FilePath(""), "", "");
28 const auto & rvsdg = rvsdgModule.Rvsdg();
29
30 const auto lambdaNode = LambdaNode::Create(
31 rvsdg.GetRootRegion(),
32 LlvmLambdaOperation::Create(functionType, "f", Linkage::externalLinkage));
33
34 auto x = lambdaNode->GetFunctionArguments()[0];
35 auto y = lambdaNode->GetFunctionArguments()[1];
36 auto ioState = lambdaNode->GetFunctionArguments()[2];
37
38 auto & ioBarrierNode = jlm::rvsdg::CreateOpNode<IOBarrierOperation>({ x, ioState }, i32Type);
39
40 auto & sdivNode =
41 jlm::rvsdg::CreateOpNode<IntegerSDivOperation>({ ioBarrierNode.output(0), y }, 32);
42
43 const auto lambdaOutput = lambdaNode->finalize({ sdivNode.output(0), ioState });
44
45 GraphExport::Create(*lambdaOutput, "f");
46
47 // Act
48 jlm::hls::IOBarrierRemoval ioBarrierRemoval;
50 ioBarrierRemoval.Run(rvsdgModule, statisticsCollector);
51
52 // Assert
53 EXPECT_FALSE(Region::containsOperation<IOBarrierOperation>(rvsdg.GetRootRegion(), true));
54}
static jlm::util::StatisticsCollector statisticsCollector
TEST(IOBarrierRemovalTests, IOBarrierRemoval)
Removes all IOBarrier nodes from the RVSDG.
void Run(rvsdg::RvsdgModule &module, util::StatisticsCollector &statisticsCollector) override
Perform RVSDG transformation.
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