summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/mesa/0001-disable-gallivm-coroutine-for-libllvm15.patch
blob: 3868052d7956c273a6ca7cd61e36af57a03731ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
From ae9611b4cf3ee3395f0e6a94073120b87ba7c520 Mon Sep 17 00:00:00 2001
From: sreenivasa murthy kolam <sreenivasamurthy.kolam@amd.com>
Date: Tue, 24 Jan 2023 17:13:36 -0800
Subject: [PATCH] Updating patch w.r.t llvm 5.4.0

---
 src/gallium/auxiliary/gallivm/lp_bld.h      | 51 +++++++++++++-
 src/gallium/auxiliary/gallivm/lp_bld_arit.c | 78 ++++++---------------
 2 files changed, 70 insertions(+), 59 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h
index 9144428..e1f6200 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld.h
@@ -81,10 +81,59 @@
 #define LLVMInsertBasicBlock ILLEGAL_LLVM_FUNCTION
 #define LLVMCreateBuilder ILLEGAL_LLVM_FUNCTION
 
-#if LLVM_VERSION_MAJOR >= 8
+#if LLVM_VERSION_MAJOR >= 15
+#define GALLIVM_HAVE_CORO 0
+#define GALLIVM_USE_NEW_PASS 1
+#elif LLVM_VERSION_MAJOR >= 8
 #define GALLIVM_HAVE_CORO 1
+#define GALLIVM_USE_NEW_PASS 0
 #else
 #define GALLIVM_HAVE_CORO 0
+#define GALLIVM_USE_NEW_PASS 0
 #endif
 
+#define GALLIVM_COROUTINES (GALLIVM_HAVE_CORO || GALLIVM_USE_NEW_PASS)
+
+/* LLVM is transitioning to "opaque pointers", and as such deprecates
+ * LLVMBuildGEP, LLVMBuildCall, LLVMBuildLoad, replacing them with
+ * LLVMBuildGEP2, LLVMBuildCall2, LLVMBuildLoad2 respectivelly.
+ * These new functions were added in LLVM 8.0; so for LLVM before 8.0 we
+ * simply forward to the non-opaque-pointer variants.
+ */
+#if LLVM_VERSION_MAJOR < 8
+
+static inline LLVMValueRef
+LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
+              LLVMValueRef Pointer, LLVMValueRef *Indices,
+              unsigned NumIndices, const char *Name)
+{
+   return LLVMBuildGEP(B, Pointer, Indices, NumIndices, Name);
+}
+
+static inline LLVMValueRef
+LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
+                      LLVMValueRef Pointer, LLVMValueRef *Indices,
+                      unsigned NumIndices, const char *Name)
+{
+   return LLVMBuildInBoundsGEP(B, Pointer, Indices, NumIndices, Name);
+}
+
+static inline LLVMValueRef
+LLVMBuildLoad2(LLVMBuilderRef B, LLVMTypeRef Ty,
+               LLVMValueRef PointerVal, const char *Name)
+{
+  LLVMValueRef val = LLVMBuildLoad(B, PointerVal, Name);
+  return LLVMTypeOf(val) == Ty ? val : LLVMBuildBitCast(B, val, Ty, Name);
+}
+
+static inline LLVMValueRef
+LLVMBuildCall2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
+               LLVMValueRef *Args, unsigned NumArgs,
+               const char *Name)
+{
+   return LLVMBuildCall(B, Fn, Args, NumArgs, Name);
+}
+
+#endif /* LLVM_VERSION_MAJOR < 8 */
+
 #endif /* LP_BLD_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index 9cff016..1dba199 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -391,16 +391,11 @@ lp_build_comp(struct lp_build_context *bld,
          return LLVMBuildNot(builder, a, "");
    }
 
-   if(LLVMIsConstant(a))
-      if (type.floating)
-          return LLVMConstFSub(bld->one, a);
-      else
-          return LLVMConstSub(bld->one, a);
+
+   if (type.floating)
+      return LLVMBuildFSub(builder, bld->one, a, "");
    else
-      if (type.floating)
-         return LLVMBuildFSub(builder, bld->one, a, "");
-      else
-         return LLVMBuildSub(builder, bld->one, a, "");
+     return LLVMBuildSub(builder, bld->one, a, "");
 }
 
 
@@ -479,16 +474,10 @@ lp_build_add(struct lp_build_context *bld,
       }
    }
 
-   if(LLVMIsConstant(a) && LLVMIsConstant(b))
-      if (type.floating)
-         res = LLVMConstFAdd(a, b);
-      else
-         res = LLVMConstAdd(a, b);
+   if (type.floating)
+      res = LLVMBuildFAdd(builder, a, b, "");
    else
-      if (type.floating)
-         res = LLVMBuildFAdd(builder, a, b, "");
-      else
-         res = LLVMBuildAdd(builder, a, b, "");
+      res = LLVMBuildAdd(builder, a, b, "");
 
    /* clamp to ceiling of 1.0 */
    if(bld->type.norm && (bld->type.floating || bld->type.fixed))
@@ -815,16 +804,10 @@ lp_build_sub(struct lp_build_context *bld,
       }
    }
 
-   if(LLVMIsConstant(a) && LLVMIsConstant(b))
-      if (type.floating)
-         res = LLVMConstFSub(a, b);
-      else
-         res = LLVMConstSub(a, b);
+   if (type.floating)
+      res = LLVMBuildFSub(builder, a, b, "");
    else
-      if (type.floating)
-         res = LLVMBuildFSub(builder, a, b, "");
-      else
-         res = LLVMBuildSub(builder, a, b, "");
+      res = LLVMBuildSub(builder, a, b, "");
 
    if(bld->type.norm && (bld->type.floating || bld->type.fixed))
       res = lp_build_max_simple(bld, res, bld->zero, GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN);
@@ -980,29 +963,16 @@ lp_build_mul(struct lp_build_context *bld,
    else
       shift = NULL;
 
-   if(LLVMIsConstant(a) && LLVMIsConstant(b)) {
-      if (type.floating)
-         res = LLVMConstFMul(a, b);
-      else
-         res = LLVMConstMul(a, b);
-      if(shift) {
-         if(type.sign)
-            res = LLVMConstAShr(res, shift);
-         else
-            res = LLVMConstLShr(res, shift);
-      }
-   }
-   else {
-      if (type.floating)
-         res = LLVMBuildFMul(builder, a, b, "");
+   if (type.floating)
+      res = LLVMBuildFMul(builder, a, b, "");
+   else
+      res = LLVMBuildMul(builder, a, b, "");
+   if (shift) {
+      if (type.sign)
+         res = LLVMBuildAShr(builder, res, shift, "");
       else
-         res = LLVMBuildMul(builder, a, b, "");
-      if(shift) {
-         if(type.sign)
-            res = LLVMBuildAShr(builder, res, shift, "");
-         else
-            res = LLVMBuildLShr(builder, res, shift, "");
-      }
+         res = LLVMBuildLShr(builder, res, shift, "");
+
    }
 
    return res;
@@ -1288,14 +1258,6 @@ lp_build_div(struct lp_build_context *bld,
    if(a == bld->undef || b == bld->undef)
       return bld->undef;
 
-   if(LLVMIsConstant(a) && LLVMIsConstant(b)) {
-      if (type.floating)
-         return LLVMConstFDiv(a, b);
-      else if (type.sign)
-         return LLVMConstSDiv(a, b);
-      else
-         return LLVMConstUDiv(a, b);
-   }
 
    /* fast rcp is disabled (just uses div), so makes no sense to try that */
    if(FALSE &&
@@ -2646,7 +2608,7 @@ lp_build_rcp(struct lp_build_context *bld,
    assert(type.floating);
 
    if(LLVMIsConstant(a))
-      return LLVMConstFDiv(bld->one, a);
+      return LLVMBuildFDiv(builder, bld->one, a, "");
 
    /*
     * We don't use RCPPS because:
-- 
2.22.0