From ed49cf9a05a0c40bd06dcbe6bb942c0cd0bfa6e2 Mon Sep 17 00:00:00 2001
From: Akash Kothari <akashk4@tyler.cs.illinois.edu>
Date: Thu, 9 Jan 2020 05:17:44 -0600
Subject: [PATCH] Committing patches

---
 .../include/Bitcode/LLVMBitCodes.h.patch      | 22 +++++++---------
 .../include/IR/Attributes.td.patch            | 17 +++++++------
 .../include/IR/Intrinsics.td.patch            |  8 +++---
 .../include/Support/Debug.h.patch             | 11 ++++++++
 .../lib/AsmParser/LLLexer.cpp.patch           | 25 ++++++++++---------
 .../lib/AsmParser/LLParser.cpp.patch          | 24 ++++++++++--------
 .../lib/AsmParser/LLToken.h.patch             | 25 ++++++++++---------
 .../Bitcode/Reader/BitcodeReader.cpp.patch    | 24 +++++++++---------
 .../Bitcode/Writer/BitcodeWriter.cpp.patch    | 12 ++++-----
 hpvm/llvm_patches/lib/IR/Attributes.cpp.patch | 14 +++++------
 10 files changed, 97 insertions(+), 85 deletions(-)

diff --git a/hpvm/llvm_patches/include/Bitcode/LLVMBitCodes.h.patch b/hpvm/llvm_patches/include/Bitcode/LLVMBitCodes.h.patch
index 8493994ff1..30da826886 100644
--- a/hpvm/llvm_patches/include/Bitcode/LLVMBitCodes.h.patch
+++ b/hpvm/llvm_patches/include/Bitcode/LLVMBitCodes.h.patch
@@ -1,16 +1,12 @@
---- ../../../include/llvm/Bitcode/LLVMBitCodes.h	2019-12-29 18:23:33.020718342 -0600
-+++ include/Bitcode/LLVMBitCodes.h	2019-12-29 18:49:23.479634563 -0600
-@@ -522,7 +522,12 @@
-   ATTR_KIND_INACCESSIBLEMEM_ONLY = 49,
-   ATTR_KIND_INACCESSIBLEMEM_OR_ARGMEMONLY = 50,
-   ATTR_KIND_ALLOC_SIZE = 51,
--  ATTR_KIND_WRITEONLY = 52
-+  ATTR_KIND_WRITEONLY = 52,
-+
-+  // VISC Attributes
-+  ATTR_KIND_IN = 53,
-+  ATTR_KIND_OUT = 54,
-+  ATTR_KIND_INOUT = 55
+--- /home/akashk4/hpvm/hpvm/llvm/include/llvm/Bitcode/LLVMBitCodes.h	2019-07-15 15:02:23.000000000 -0500
++++ include/Bitcode/LLVMBitCodes.h	2020-01-09 00:27:16.654327975 -0600
+@@ -632,6 +632,9 @@
+   ATTR_KIND_NOFREE = 62,
+   ATTR_KIND_NOSYNC = 63,
+   ATTR_KIND_SANITIZE_MEMTAG = 64,
++  ATTR_KIND_IN = 65,
++  ATTR_KIND_OUT = 66,
++  ATTR_KIND_INOUT = 67,
  };
  
  enum ComdatSelectionKindCodes {
diff --git a/hpvm/llvm_patches/include/IR/Attributes.td.patch b/hpvm/llvm_patches/include/IR/Attributes.td.patch
index 429bf7b215..d2dac7ba94 100644
--- a/hpvm/llvm_patches/include/IR/Attributes.td.patch
+++ b/hpvm/llvm_patches/include/IR/Attributes.td.patch
@@ -1,8 +1,8 @@
---- ../../../include/llvm/IR/Attributes.td	2019-12-29 18:23:33.793781744 -0600
-+++ include/IR/Attributes.td	2019-12-30 00:56:38.540423304 -0600
-@@ -173,6 +173,16 @@
- /// Zero extended before/after call.
- def ZExt : EnumAttr<"zeroext">;
+--- /home/akashk4/hpvm/hpvm/llvm/include/llvm/IR/Attributes.td	2019-07-15 15:02:23.000000000 -0500
++++ include/IR/Attributes.td	2020-01-09 00:27:16.659328383 -0600
+@@ -151,6 +151,17 @@
+ /// Sign extended before/after call.
+ def SExt : EnumAttr<"signext">;
  
 +/// VISC Attributes
 +/// Pointer to read only memory
@@ -14,6 +14,7 @@
 +/// Pointer to read/write memory
 +def InOut : EnumAttr<"inout">;
 +
- /// Target-independent string attributes.
- def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">;
- def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">;
++
+ /// Alignment of stack for function (3 bits)  stored as log2 of alignment with
+ /// +1 bias 0 means unaligned (different from alignstack=(1)).
+ def StackAlignment : EnumAttr<"alignstack">;
diff --git a/hpvm/llvm_patches/include/IR/Intrinsics.td.patch b/hpvm/llvm_patches/include/IR/Intrinsics.td.patch
index cd27481ca5..8f18304595 100644
--- a/hpvm/llvm_patches/include/IR/Intrinsics.td.patch
+++ b/hpvm/llvm_patches/include/IR/Intrinsics.td.patch
@@ -1,7 +1,7 @@
---- ../../../include/llvm/IR/Intrinsics.td	2019-12-29 18:23:33.896790192 -0600
-+++ include/IR/Intrinsics.td	2019-12-29 18:50:41.881046510 -0600
-@@ -761,3 +761,4 @@
- include "llvm/IR/IntrinsicsBPF.td"
+--- /home/akashk4/hpvm/hpvm/llvm/include/llvm/IR/Intrinsics.td	2019-07-17 10:15:43.000000000 -0500
++++ include/IR/Intrinsics.td	2020-01-09 00:27:16.663328710 -0600
+@@ -1249,3 +1249,4 @@
  include "llvm/IR/IntrinsicsSystemZ.td"
  include "llvm/IR/IntrinsicsWebAssembly.td"
+ include "llvm/IR/IntrinsicsRISCV.td"
 +include "llvm/IR/IntrinsicsVISC.td"
diff --git a/hpvm/llvm_patches/include/Support/Debug.h.patch b/hpvm/llvm_patches/include/Support/Debug.h.patch
index e69de29bb2..4db5c09045 100644
--- a/hpvm/llvm_patches/include/Support/Debug.h.patch
+++ b/hpvm/llvm_patches/include/Support/Debug.h.patch
@@ -0,0 +1,11 @@
+--- /home/akashk4/hpvm/hpvm/llvm/include/llvm/Support/Debug.h	2019-01-19 02:50:56.000000000 -0600
++++ include/Support/Debug.h	2020-01-09 00:27:16.671329363 -0600
+@@ -121,6 +121,8 @@
+ //
+ #define LLVM_DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X)
+ 
++#define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X)
++
+ } // end namespace llvm
+ 
+ #endif // LLVM_SUPPORT_DEBUG_H
diff --git a/hpvm/llvm_patches/lib/AsmParser/LLLexer.cpp.patch b/hpvm/llvm_patches/lib/AsmParser/LLLexer.cpp.patch
index c0fbc644cb..2d0a972ea4 100644
--- a/hpvm/llvm_patches/lib/AsmParser/LLLexer.cpp.patch
+++ b/hpvm/llvm_patches/lib/AsmParser/LLLexer.cpp.patch
@@ -1,13 +1,14 @@
---- ../../../lib/AsmParser/LLLexer.cpp	2019-12-29 18:23:35.457918227 -0600
-+++ lib/AsmParser/LLLexer.cpp	2019-12-29 18:44:36.376156576 -0600
-@@ -660,6 +660,10 @@
-   KEYWORD(uwtable);
-   KEYWORD(writeonly);
-   KEYWORD(zeroext);
-+  // VISC parameter attributes
-+  KEYWORD(in);
-+  KEYWORD(out);
-+  KEYWORD(inout);
+--- /home/akashk4/hpvm/hpvm/llvm/lib/AsmParser/LLLexer.cpp	2019-07-15 15:02:23.000000000 -0500
++++ lib/AsmParser/LLLexer.cpp	2020-01-09 00:27:16.678329935 -0600
+@@ -800,6 +800,11 @@
+   KEYWORD(bit);
+   KEYWORD(varFlags);
  
-   KEYWORD(type);
-   KEYWORD(opaque);
++// VISC parameter attributes
++   KEYWORD(in);
++   KEYWORD(out);
++   KEYWORD(inout);
++
+ #undef KEYWORD
+ 
+   // Keywords for types.
diff --git a/hpvm/llvm_patches/lib/AsmParser/LLParser.cpp.patch b/hpvm/llvm_patches/lib/AsmParser/LLParser.cpp.patch
index 632cb9488d..339488ac08 100644
--- a/hpvm/llvm_patches/lib/AsmParser/LLParser.cpp.patch
+++ b/hpvm/llvm_patches/lib/AsmParser/LLParser.cpp.patch
@@ -1,32 +1,34 @@
---- ../../../lib/AsmParser/LLParser.cpp	2019-12-29 18:23:35.463918719 -0600
-+++ lib/AsmParser/LLParser.cpp	2019-12-29 18:44:13.295269292 -0600
-@@ -1138,6 +1138,11 @@
-     case lltok::kw_sret:
+--- /home/akashk4/hpvm/hpvm/llvm/lib/AsmParser/LLParser.cpp	2019-07-15 15:02:23.000000000 -0500
++++ lib/AsmParser/LLParser.cpp	2020-01-09 00:27:16.690330915 -0600
+@@ -1346,6 +1346,11 @@
      case lltok::kw_swifterror:
      case lltok::kw_swiftself:
+     case lltok::kw_immarg:
++    
 +    // VISC Parameter only attributes
 +    case lltok::kw_in:
 +    case lltok::kw_out:
 +    case lltok::kw_inout:
-+
        HaveError |=
          Error(Lex.getLoc(),
                "invalid use of parameter-only attribute on a function");
-@@ -1413,6 +1418,10 @@
-     case lltok::kw_swiftself:       B.addAttribute(Attribute::SwiftSelf); break;
-     case lltok::kw_writeonly:       B.addAttribute(Attribute::WriteOnly); break;
+@@ -1647,6 +1652,11 @@
      case lltok::kw_zeroext:         B.addAttribute(Attribute::ZExt); break;
+     case lltok::kw_immarg:          B.addAttribute(Attribute::ImmArg); break;
+ 
 +    // VISC parameter attributes
 +    case lltok::kw_in:              B.addAttribute(Attribute::In); break;
 +    case lltok::kw_out:             B.addAttribute(Attribute::Out); break;
 +    case lltok::kw_inout:           B.addAttribute(Attribute::InOut); break;
- 
++
      case lltok::kw_alignstack:
      case lltok::kw_alwaysinline:
-@@ -1501,6 +1510,10 @@
-     case lltok::kw_sret:
+     case lltok::kw_argmemonly:
+@@ -1742,6 +1752,11 @@
      case lltok::kw_swifterror:
      case lltok::kw_swiftself:
+     case lltok::kw_immarg:
++
 +    // VISC Parameter only attributes
 +    case lltok::kw_in:
 +    case lltok::kw_out:
diff --git a/hpvm/llvm_patches/lib/AsmParser/LLToken.h.patch b/hpvm/llvm_patches/lib/AsmParser/LLToken.h.patch
index fc3b2e05cf..900be4996d 100644
--- a/hpvm/llvm_patches/lib/AsmParser/LLToken.h.patch
+++ b/hpvm/llvm_patches/lib/AsmParser/LLToken.h.patch
@@ -1,13 +1,14 @@
---- ../../../lib/AsmParser/LLToken.h	2019-12-29 18:23:35.468919129 -0600
-+++ lib/AsmParser/LLToken.h	2019-12-29 18:44:52.957512419 -0600
-@@ -209,6 +209,10 @@
-   kw_uwtable,
-   kw_writeonly,
-   kw_zeroext,
-+  // VISC parameter attributes
-+  kw_in,
-+  kw_out,
-+  kw_inout,
+--- /home/akashk4/hpvm/hpvm/llvm/lib/AsmParser/LLToken.h	2019-07-15 15:02:23.000000000 -0500
++++ lib/AsmParser/LLToken.h	2020-01-09 00:27:16.696331405 -0600
+@@ -351,6 +351,11 @@
+   kw_insertvalue,
+   kw_blockaddress,
+ 
++   // VISC parameter attributes
++   kw_in, 
++   kw_out,
++   kw_inout,
++
+   // Metadata types.
+   kw_distinct,
  
-   kw_type,
-   kw_opaque,
diff --git a/hpvm/llvm_patches/lib/Bitcode/Reader/BitcodeReader.cpp.patch b/hpvm/llvm_patches/lib/Bitcode/Reader/BitcodeReader.cpp.patch
index 638614a7f9..82caa0656d 100644
--- a/hpvm/llvm_patches/lib/Bitcode/Reader/BitcodeReader.cpp.patch
+++ b/hpvm/llvm_patches/lib/Bitcode/Reader/BitcodeReader.cpp.patch
@@ -1,15 +1,15 @@
---- ../../../lib/Bitcode/Reader/BitcodeReader.cpp	2019-12-29 18:23:35.483920360 -0600
-+++ lib/Bitcode/Reader/BitcodeReader.cpp	2019-12-29 18:46:57.005656131 -0600
-@@ -1066,6 +1066,12 @@
-   case Attribute::SwiftSelf:       return 1ULL << 51;
-   case Attribute::SwiftError:      return 1ULL << 52;
-   case Attribute::WriteOnly:       return 1ULL << 53;
+--- /home/akashk4/hpvm/hpvm/llvm/lib/Bitcode/Reader/BitcodeReader.cpp	2019-07-15 15:02:23.000000000 -0500
++++ lib/Bitcode/Reader/BitcodeReader.cpp	2020-01-09 00:27:16.708332385 -0600
+@@ -1280,6 +1280,12 @@
+     return 1ULL << 62;
+   case Attribute::NoFree:
+     return 1ULL << 63;
 +
-+  // VISC Attributes
-+  case Attribute::In:                return 1ULL << 54;
-+  case Attribute::Out:               return 1ULL << 55;
-+  case Attribute::InOut:             return 1ULL << 56;
++   // VISC Attributes
++  case Attribute::In:              return 3ULL << 0;
++  case Attribute::Out:             return 3ULL << 1;  
++  case Attribute::InOut:           return 3ULL << 2;
 +
-   case Attribute::Dereferenceable:
-     llvm_unreachable("dereferenceable attribute not supported in raw format");
+   case Attribute::NoSync:
+     llvm_unreachable("nosync attribute not supported in raw format");
      break;
diff --git a/hpvm/llvm_patches/lib/Bitcode/Writer/BitcodeWriter.cpp.patch b/hpvm/llvm_patches/lib/Bitcode/Writer/BitcodeWriter.cpp.patch
index 18a91b2c7c..d2492681d9 100644
--- a/hpvm/llvm_patches/lib/Bitcode/Writer/BitcodeWriter.cpp.patch
+++ b/hpvm/llvm_patches/lib/Bitcode/Writer/BitcodeWriter.cpp.patch
@@ -1,9 +1,9 @@
---- ../../../lib/Bitcode/Writer/BitcodeWriter.cpp	2019-12-29 18:23:35.504922082 -0600
-+++ lib/Bitcode/Writer/BitcodeWriter.cpp	2019-12-29 18:47:13.430999323 -0600
-@@ -699,6 +699,15 @@
-     return bitc::ATTR_KIND_WRITEONLY;
-   case Attribute::ZExt:
-     return bitc::ATTR_KIND_Z_EXT;
+--- /home/akashk4/hpvm/hpvm/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp	2019-07-15 15:02:23.000000000 -0500
++++ lib/Bitcode/Writer/BitcodeWriter.cpp	2020-01-09 00:27:16.716333039 -0600
+@@ -725,6 +725,15 @@
+     return bitc::ATTR_KIND_IMMARG;
+   case Attribute::SanitizeMemTag:
+     return bitc::ATTR_KIND_SANITIZE_MEMTAG;
 +
 +  // VISC Attributes
 +  case Attribute::In:
diff --git a/hpvm/llvm_patches/lib/IR/Attributes.cpp.patch b/hpvm/llvm_patches/lib/IR/Attributes.cpp.patch
index d24aa09232..8f112fa220 100644
--- a/hpvm/llvm_patches/lib/IR/Attributes.cpp.patch
+++ b/hpvm/llvm_patches/lib/IR/Attributes.cpp.patch
@@ -1,8 +1,8 @@
---- ../../../lib/IR/Attributes.cpp	2019-12-29 18:23:36.965041833 -0600
-+++ lib/IR/Attributes.cpp	2019-12-29 18:48:27.129026177 -0600
+--- /home/akashk4/hpvm/hpvm/llvm/lib/IR/Attributes.cpp	2019-07-15 15:02:23.000000000 -0500
++++ lib/IR/Attributes.cpp	2020-01-09 00:27:16.722333529 -0600
 @@ -396,6 +396,14 @@
-     return Result;
-   }
+   if (hasAttribute(Attribute::ImmArg))
+     return "immarg";
  
 +  // VISC attributes for arguments
 +  if (hasAttribute(Attribute::In))
@@ -12,6 +12,6 @@
 +  if (hasAttribute(Attribute::InOut))
 +    return "inout";
 +
-   llvm_unreachable("Unknown attribute");
- }
- 
+   if (hasAttribute(Attribute::ByVal)) {
+     std::string Result;
+     Result += "byval";
-- 
GitLab