From cba16207875d3b23eb7b3b575b1239cae2b75a82 Mon Sep 17 00:00:00 2001
From: Akash Kothari <akashk4@tyler.cs.illinois.edu>
Date: Mon, 21 Dec 2020 11:51:11 -0600
Subject: [PATCH] LLVM-9-Port ApproxHPVM headers

---
 .../ExtractHPVMLeafNodes.h                    | 37 ++++++++++---------
 .../FuseHPVMTensorNodes/FuseHPVMTensorNodes.h | 24 ++++++------
 hpvm/include/InPlaceDFG/InPlaceDFGAnalysis.h  |  4 +-
 hpvm/include/SupportHPVM/DFGTreeTraversal.h   |  2 +-
 hpvm/include/SupportHPVM/DFGraph.h            | 12 +++++-
 5 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/hpvm/include/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.h b/hpvm/include/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.h
index dfbd09402d..97e91f5e07 100644
--- a/hpvm/include/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.h
+++ b/hpvm/include/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.h
@@ -1,25 +1,26 @@
 #ifndef __EXTRACT_HPVM_LEAF_NODE_FUNCTIONS_H__
-	#define __EXTRACT_HPVM_LEAF_NODE_FUNCTIONS_H__
+#define __EXTRACT_HPVM_LEAF_NODE_FUNCTIONS_H__
 	
-	//===-------------------- ExtractHPVMLeafNodeFunctions.h ------------------===//
-	//
-	//                     The LLVM Compiler Infrastructure
-	//
-	// This file is distributed under the University of Illinois Open Source
-	// License. See LICENSE.TXT for details.
-	//
-	//===----------------------------------------------------------------------===//
+//===-------------------- ExtractHPVMLeafNodeFunctions.h ------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
 	
-	#include "llvm/IR/Module.h"
-	#include "llvm/BuildDFG/BuildDFG.h"
+#include "llvm/IR/Module.h"
+
+#include "BuildDFG/BuildDFG.h"
 	
-	namespace extracthpvmleaf {
+namespace extracthpvmleaf {
 	
-	class ExtractHPVMLeafNodeFunctions {
-	public:
-	  void run(Module &M, builddfg::BuildDFG &DFG);
-	};
+class ExtractHPVMLeafNodeFunctions {
+public:
+    void run(Module &M, builddfg::BuildDFG &DFG);
+};
 	
-	} // end namespace extracthpvmleaf
+} // end namespace extracthpvmleaf
 	
-	#endif
\ No newline at end of file
+#endif
diff --git a/hpvm/include/FuseHPVMTensorNodes/FuseHPVMTensorNodes.h b/hpvm/include/FuseHPVMTensorNodes/FuseHPVMTensorNodes.h
index 72812071a3..ce6725b930 100644
--- a/hpvm/include/FuseHPVMTensorNodes/FuseHPVMTensorNodes.h
+++ b/hpvm/include/FuseHPVMTensorNodes/FuseHPVMTensorNodes.h
@@ -10,12 +10,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/IR/DFGraph.h"
+#include "SupportHPVM/DFGraph.h"
+
 #include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
 
-#include "llvm/BuildDFG/BuildDFG.h"
-#include "llvm/SupportVISC/DFG2LLVM.h"
+#include "BuildDFG/BuildDFG.h"
+#include "SupportHPVM/DFG2LLVM.h"
 
 using namespace llvm;
 
@@ -113,7 +114,7 @@ public:
 class FindFusionTargetsTraversal : public dfg2llvm::CodeGenTraversal {
 
 private:
-  typedef std::map< visc::Target, std::vector< std::vector<Intrinsic::ID> > >
+  typedef std::map< hpvm::Target, std::vector< std::vector<Intrinsic::ID> > >
           FusePatterns;
   //Member variables
 
@@ -137,14 +138,14 @@ public:
 
   FindFusionTargetsTraversal(Module &_M, builddfg::BuildDFG &_DFG) :
     CodeGenTraversal(_M, _DFG) {
-/*    FPs[visc::PROMISE_TARGET] = { {Intrinsic::visc_tensor_conv,
-                                   Intrinsic::visc_tensor_add,
-                                   Intrinsic::visc_tensor_relu,
-                                   Intrinsic::visc_tensor_pooling
+/*    FPs[hpvm::PROMISE_TARGET] = { {Intrinsic::visc_tensor_conv,
+                                   Intrinsic::hpvm_tensor_add,
+                                   Intrinsic::hpvm_tensor_relu,
+                                   Intrinsic::hpvm_tensor_pooling
                                   },
-                                  {Intrinsic::visc_tensor_mul,
-                                   Intrinsic::visc_tensor_add,
-                                   Intrinsic::visc_tensor_relu
+                                  {Intrinsic::hpvm_tensor_mul,
+                                   Intrinsic::hpvm_tensor_add,
+                                   Intrinsic::hpvm_tensor_relu
                                   }
                                 }
 */
@@ -176,3 +177,4 @@ public:
 } // End of namespace
 
 #endif
+
diff --git a/hpvm/include/InPlaceDFG/InPlaceDFGAnalysis.h b/hpvm/include/InPlaceDFG/InPlaceDFGAnalysis.h
index fc4c7f3ee9..820b274eb6 100644
--- a/hpvm/include/InPlaceDFG/InPlaceDFGAnalysis.h
+++ b/hpvm/include/InPlaceDFG/InPlaceDFGAnalysis.h
@@ -12,8 +12,8 @@
 
 #include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
-#include "llvm/IR/DFGraph.h"
-#include "llvm/BuildDFG/BuildDFG.h"
+#include "SupportHPVM/DFGraph.h"
+#include "BuildDFG/BuildDFG.h"
 
 using namespace llvm;
 
diff --git a/hpvm/include/SupportHPVM/DFGTreeTraversal.h b/hpvm/include/SupportHPVM/DFGTreeTraversal.h
index 67c317a2e9..e357bb3dd9 100644
--- a/hpvm/include/SupportHPVM/DFGTreeTraversal.h
+++ b/hpvm/include/SupportHPVM/DFGTreeTraversal.h
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/BuildDFG/BuildDFG.h"
+#include "BuildDFG/BuildDFG.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
diff --git a/hpvm/include/SupportHPVM/DFGraph.h b/hpvm/include/SupportHPVM/DFGraph.h
index 2deb2ca8f5..e7f3c5bc78 100644
--- a/hpvm/include/SupportHPVM/DFGraph.h
+++ b/hpvm/include/SupportHPVM/DFGraph.h
@@ -761,12 +761,14 @@ DFEdge *DFNode::getOutDFEdgeAt(unsigned outPort) {
 
   // Cannot perform check for the number of outputs here,
   // it depends on the node's return type
-
+  
+  unsigned index = 0;
   for (outdfedge_iterator i = outdfedge_begin(), e = outdfedge_end(); i != e;
        ++i) {
     DFEdge *E = *i;
-    if (outPort == E->getSourcePosition())
+    if (outPort == index)//E->getSourcePosition())
       return E;
+    index++;
   }
   return NULL;
 }
@@ -855,8 +857,11 @@ bool DFNode::hasSideEffects() {
 
 //===--------------------- DFInternalNode Outlined Functions --------------===//
 void DFInternalNode::addEdgeToDFGraph(DFEdge *E) {
+  errs() << "----- ADD EDGE TO DFGRAPH\n";
   DFNode *S = E->getSourceDF();
   DFNode *D = E->getDestDF();
+  errs() << "INIT SOURCE NODE: " << S << "\n";
+  errs() << "INIT DEST NODE: " << D << "\n";
 
   assert(std::find(childGraph->begin(), childGraph->end(), S) !=
              childGraph->end() &&
@@ -874,6 +879,9 @@ void DFInternalNode::addEdgeToDFGraph(DFEdge *E) {
   S->addOutDFEdge(E);
   D->addInDFEdge(E);
 
+  errs() << "SET SOURCE NODE: " << E->getSourceDF() << "\n";
+  errs() << "SET DEST NODE: " << E->getDestDF() << "\n";
+
   // Update Rank
   if (D->getRank() <= S->getRank())
     D->setRank(S->getRank() + 1);
-- 
GitLab