[llvm] [SandboxVec][DAG] Boilerplate (PR #108862)
Jorge Gorbe Moya via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 17:49:38 PDT 2024
================
@@ -0,0 +1,64 @@
+//===- DependencyGraph.cpp ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h"
+
+using namespace llvm::sandboxir;
+
+#ifndef NDEBUG
+void DGNode::print(raw_ostream &OS, bool PrintDeps) const {
+ I->dumpOS(OS);
+ if (PrintDeps) {
+ OS << "\n";
+ // Print memory preds.
+ static constexpr const unsigned Indent = 4;
+ for (auto *Pred : MemPreds) {
+ OS.indent(Indent) << "<-";
+ Pred->print(OS, false);
+ OS << "\n";
+ }
+ }
+}
+void DGNode::dump() const {
+ print(dbgs());
+ dbgs() << "\n";
+}
+#endif // NDEBUG
+
+void DependencyGraph::extend(BasicBlock *BB) {
+ if (BB->empty())
+ return;
+ // TODO: For now create a chain of dependencies.
+ DGNode *LastN = getOrCreateNode(&*BB->begin());
+ for (auto &I : drop_begin(*BB)) {
+ auto *N = getOrCreateNode(&I);
+ N->addMemPred(LastN);
+ LastN = N;
+ }
+}
+
+#ifndef NDEBUG
+void DependencyGraph::print(raw_ostream &OS) const {
+ // InstrToNodeMap is unoredred so we need to create an ordered vector.
----------------
slackito wrote:
typo: unordered
https://github.com/llvm/llvm-project/pull/108862
More information about the llvm-commits
mailing list