Jlm
RecursiveDataTests.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 
6 #include <gtest/gtest.h>
7 
12 #include <jlm/rvsdg/TestType.hpp>
13 #include <jlm/rvsdg/view.hpp>
14 #include <jlm/util/Statistics.hpp>
15 
16 TEST(RecursiveDataTests, test)
17 {
18  using namespace jlm::llvm;
19  using namespace jlm::rvsdg;
20 
22  auto pointerType = PointerType::Create();
24 
25  auto d0 = DataNode::Create(im.ipgraph(), "d0", vt, Linkage::externalLinkage, "", false, 4);
26 
27  auto d1 = DataNode::Create(im.ipgraph(), "d1", vt, Linkage::externalLinkage, "", false, 4);
28  auto d2 = DataNode::Create(im.ipgraph(), "d2", vt, Linkage::externalLinkage, "", false, 4);
29 
30  auto v0 = im.create_global_value(d0);
31  auto v1 = im.create_global_value(d1);
32  auto v2 = im.create_global_value(d2);
33 
34  d1->add_dependency(d0);
35  d1->add_dependency(d2);
36  d2->add_dependency(d0);
37  d2->add_dependency(d1);
38 
39  tacsvector_t tvec1, tvec2;
40  tvec1.push_back(ThreeAddressCode::create(
41  TestOperation::create({ pointerType, pointerType }, { vt }),
42  { v0, v2 }));
43  tvec2.push_back(ThreeAddressCode::create(
44  TestOperation::create({ pointerType, pointerType }, { vt }),
45  { v0, v1 }));
46 
47  d1->set_initialization(std::make_unique<DataNodeInit>(std::move(tvec1)));
48  d2->set_initialization(std::make_unique<DataNodeInit>(std::move(tvec2)));
49 
52 
53  jlm::rvsdg::view(rvsdgModule->Rvsdg(), stdout);
54 }
static jlm::util::StatisticsCollector statisticsCollector
static const auto vt
Definition: PullTests.cpp:16
TEST(RecursiveDataTests, test)
static DataNode * Create(InterProceduralGraph &clg, const std::string &name, std::shared_ptr< const jlm::rvsdg::Type > valueType, const llvm::Linkage &linkage, std::string section, const bool constant, const size_t alignment)
Definition: ipgraph.hpp:431
GlobalValue * create_global_value(DataNode *node)
InterProceduralGraph & ipgraph() noexcept
static std::shared_ptr< const PointerType > Create()
Definition: types.cpp:45
static std::unique_ptr< llvm::ThreeAddressCode > create(std::unique_ptr< rvsdg::SimpleOperation > operation, const std::vector< const Variable * > &operands)
Definition: tac.hpp:135
static std::shared_ptr< const TestType > createValueType()
Definition: TestType.cpp:67
Global memory state passed between functions.
std::vector< std::unique_ptr< llvm::ThreeAddressCode > > tacsvector_t
Definition: tac.hpp:202
static std::unique_ptr< LlvmRvsdgModule > ConvertInterProceduralGraphModule(InterProceduralGraphModule &interProceduralGraphModule, InterProceduralGraphToRvsdgStatisticsCollector &statisticsCollector)
std::string view(const rvsdg::Region *region)
Definition: view.cpp:142