From e0cb645fe29ce3059cc5c935736c9d0509ce2d9b Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@miranda.cs.illinois.edu>
Date: Sat, 26 Jun 2021 18:10:34 -0500
Subject: [PATCH] Modifying hpvm-clang to skip CPU backend and link steps

---
 hpvm/tools/hpvm-clang/main.py.in | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/hpvm/tools/hpvm-clang/main.py.in b/hpvm/tools/hpvm-clang/main.py.in
index 65414803ad..0c047de043 100644
--- a/hpvm/tools/hpvm-clang/main.py.in
+++ b/hpvm/tools/hpvm-clang/main.py.in
@@ -75,8 +75,11 @@ def compile_hpvm_c(
     if opencl:
         passes += ["LLVMDFG2LLVM_OpenCL"]
         pass_flags += ["dfg2llvm-opencl"]
+        
     passes += ["LLVMDFG2LLVM_CPU", "LLVMClearDFG"]
-    pass_flags += ["dfg2llvm-cpu", "clearDFG"]
+
+    if tensor_target != "nvdla":
+        pass_flags += ["dfg2llvm-cpu", "clearDFG"]
 
     working_dir = Path(working_dir or ".")
     if not working_dir.is_dir():
@@ -89,15 +92,20 @@ def compile_hpvm_c(
     llvm_ll_file = working_dir / f"{name_stem}.llvm.ll"
     hpvm_rt_linked_file = working_dir / f"{name_stem}.linked.bc"
     link_bitcode_ = [Path(bc) for bc in (link_bitcode or [])]
+
+    
     commands = [
         hpvm_c_to_ll(hpvm_src, ll_file, include, macro, flags, optim_level, is_cpp, std),
         opt_codegen_hpvm(ll_file, hpvm_ll_file),
         _run_opt(hpvm_ll_file, llvm_ll_file, passes, pass_flags),
         link_hpvm_rt(link_bitcode_ + [llvm_ll_file], hpvm_rt_linked_file),
     ]
-    commands.append(
-        link_binary(hpvm_rt_linked_file, output_file, link_dirs, link_libs)
-    )
+
+    if tensor_target != "nvdla":
+        commands.append(
+            link_binary(hpvm_rt_linked_file, output_file, link_dirs, link_libs)
+        )
+        
     for command in commands:
         if verbose:
             print(" ".join(command))
-- 
GitLab