51#include <llvm/IR/LLVMContext.h>
52#include <llvm/IR/Module.h>
53#include <llvm/Support/raw_ostream.h>
54#include <llvm/Support/SourceMgr.h>
103 if (std::regex_match(
123 else if (argument ==
nullptr)
127 else if (argument->region() == &graph->GetRootRegion())
159 if (
graphImport->Name().rfind(
"decouple_", 0) == 0)
187 auto op = util::assertedCast<const llvm::LlvmDeltaOperation>(&
odn->GetOperation());
188 auto name =
op->name();
197 std::cout <<
"renaming delta node " <<
op->name() <<
" to " << name <<
"\n";
206 op->getAlignment()));
209 for (
auto ctxVar :
odn->GetContextVars())
211 auto input =
ctxVar.input;
212 auto nd =
db->AddContextVar(*input->origin()).inner;
217 odn->subregion()->copy(
db->subregion(),
rmap);
219 auto result = &
rmap.lookup(*
odn->subregion()->result(0)->origin());
220 auto data = &
db->finalize(result);
222 odn->output().divert_users(data);
237 op.callingConvention(),
242 for (
const auto &
cv :
ln->GetContextVars())
244 auto origin =
cv.input->origin();
245 auto newcv = lambda->AddContextVar(*origin);
249 auto args =
ln->GetFunctionArguments();
250 auto newArgs = lambda->GetFunctionArguments();
252 for (std::size_t
n = 0;
n <
args.size(); ++
n)
261 std::vector<jlm::rvsdg::Output *> results;
262 for (
auto result :
ln->GetFunctionResults())
263 results.push_back(&
subregionmap.lookup(*result->origin()));
266 lambda->finalize(results);
274std::unique_ptr<jlm::llvm::LlvmRvsdgModule>
281 std::cout <<
"processing " <<
rm.SourceFileName().name() <<
"\n";
282 auto root = &
rm.Rvsdg().GetRootRegion();
295 for (
size_t i = 0;
i <
ln->ninputs(); ++
i)
310 "Inlining of function "
316 auto op = util::assertedCast<const llvm::LlvmDeltaOperation>(&
odn->GetOperation());
318 if (
op->name().find(
'.') != std::string::npos)
321 op = util::assertedCast<const llvm::LlvmDeltaOperation>(&
odn->GetOperation());
323 std::cout <<
"delta node " <<
op->name() <<
": " <<
op->Type()->debug_string() <<
"\n";
358 std::cout <<
"function "
360 <<
" extracted for HLS\n";
373std::unique_ptr<rvsdg::TransformationSequence>
386 auto gammaMerge = std::make_shared<GammaMerge>();
397 auto nodeReduction = std::make_shared<llvm::NodeReduction>();
406 [[
maybe_unused]]
auto dumpDot = std::make_shared<DumpDotTransformation>();
408 std::vector<std::shared_ptr<rvsdg::Transformation>>
sequence({
450 return std::make_unique<rvsdg::TransformationSequence>(
459 const std::unique_ptr<llvm::LlvmRvsdgModule> reference(
463 for (
size_t i = 0;
i < reference->Rvsdg().GetRootRegion().narguments(); ++
i)
465 auto graphImport = util::assertedCast<const llvm::LlvmGraphImport>(
466 reference->Rvsdg().GetRootRegion().argument(
i));
470 ::llvm::LLVMContext
ctx;
476 lm2->print(
os,
nullptr);
static jlm::util::StatisticsCollector statisticsCollector
Common Node Elimination This is mainly a copy of the CNE optimization in the LLVM backend with the ad...
rvsdg::GraphExport * GetRvsdgExport() const noexcept
Dead Node Elimination Optimization.
static void inlineCall(rvsdg::SimpleNode &callNode, rvsdg::LambdaNode &caller, const rvsdg::LambdaNode &callee)
Invariant Value Redirection.
static std::unique_ptr<::llvm::Module > CreateAndConvertModule(InterProceduralGraphModule &ipGraphModule, ::llvm::LLVMContext &ctx)
static std::unique_ptr< LlvmDeltaOperation > Create(std::shared_ptr< const rvsdg::Type > type, const std::string &name, const Linkage &linkage, std::string section, bool constant, const size_t alignment)
static LlvmGraphImport & createGlobalImport(rvsdg::Graph &graph, std::shared_ptr< const rvsdg::Type > valueType, std::shared_ptr< const rvsdg::Type > importedType, std::string name, Linkage linkage, const bool isConstant, const size_t alignment)
LlvmGraphImport & Copy(rvsdg::Region ®ion, rvsdg::StructuralInput *input) const override
static LlvmGraphImport & createFunctionImport(rvsdg::Graph &graph, std::shared_ptr< const rvsdg::FunctionType > functionType, std::string name, Linkage linkage, CallingConvention callingConvention)
static std::unique_ptr< LlvmLambdaOperation > Create(std::shared_ptr< const jlm::rvsdg::FunctionType > type, std::string name, const jlm::llvm::Linkage &linkage, jlm::llvm::CallingConvention callingConvention, jlm::llvm::AttributeSet attributes)
const std::string & name() const noexcept
static std::unique_ptr< LlvmRvsdgModule > Create(const util::FilePath &sourceFileName, const std::string &targetTriple, const std::string &dataLayout)
static std::shared_ptr< const LoopUnswitchingDefaultHeuristic > create()
static std::shared_ptr< const PointerType > Create()
static std::unique_ptr< InterProceduralGraphModule > CreateAndConvertModule(LlvmRvsdgModule &rvsdgModule, util::StatisticsCollector &statisticsCollector)
static DeltaNode * Create(rvsdg::Region *parent, std::unique_ptr< DeltaOperation > op)
static GraphExport & Create(Output &origin, std::string name)
static LambdaNode * Create(rvsdg::Region &parent, std::unique_ptr< LambdaOperation > operation)
Represents the argument of a region.
Represent acyclic RVSDG subgraphs.
Graph * graph() const noexcept
void insert(const Output *original, Output *substitute)
const std::string & to_str() const noexcept
bool function_match(rvsdg::LambdaNode *ln, const std::string &function_name)
void split_opt(llvm::LlvmRvsdgModule &rm)
void inline_calls(rvsdg::Region *region)
rvsdg::DeltaNode * rename_delta(rvsdg::DeltaNode *odn)
static void divert_users(jlm::rvsdg::Output *output, Context &ctx)
std::unique_ptr< rvsdg::TransformationSequence > createTransformationSequence(rvsdg::DotWriter &dotWriter, const bool dumpRvsdgGraphs)
void instrument_ref(llvm::LlvmRvsdgModule &rm)
void dump_ref(llvm::LlvmRvsdgModule &rhls, const util::FilePath &path)
void pre_opt(jlm::llvm::LlvmRvsdgModule &rm)
std::unique_ptr< jlm::llvm::LlvmRvsdgModule > split_hls_function(llvm::LlvmRvsdgModule &rm, const std::string &function_name)
rvsdg::LambdaNode * change_linkage(rvsdg::LambdaNode *ln, llvm::Linkage link)
const jlm::rvsdg::Output * trace_call(jlm::rvsdg::Input *input)
void rvsdg2ref(llvm::LlvmRvsdgModule &rhls, const util::FilePath &path)
CallSummary ComputeCallSummary(const rvsdg::LambdaNode &lambdaNode)
static void remove(Node *node)
static std::vector< jlm::rvsdg::Output * > outputs(const Node *node)
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
detail::TopDownTraverserGeneric< false > TopDownTraverser
Traverser for visiting every node in a region in a top down order.