Contents of /trunk/mesa/patches/mesa-9.0.2-llvm32.patch
Parent Directory | Revision Log
Revision 2055 -
(show annotations)
(download)
Tue Jan 29 14:51:14 2013 UTC (11 years, 7 months ago) by niro
File size: 10862 byte(s)
Tue Jan 29 14:51:14 2013 UTC (11 years, 7 months ago) by niro
File size: 10862 byte(s)
-support llvm-3.2
1 | From 8d9778589f4b3a174e884338adb0fe1bdeca5eb7 Mon Sep 17 00:00:00 2001 |
2 | From: Tom Stellard <thomas.stellard@amd.com> |
3 | Date: Thu, 10 May 2012 14:21:54 +0000 |
4 | Subject: radeon: Support LLVM 3.2 |
5 | |
6 | LLVM 3.2 and newer requires that the R600/SI backend be part of the |
7 | LLVM tree. |
8 | --- |
9 | diff --git a/configure.ac b/configure.ac |
10 | index 896f98a..32f412b 100644 |
11 | --- a/configure.ac |
12 | +++ b/configure.ac |
13 | @@ -1661,6 +1661,7 @@ if test "x$enable_gallium_llvm" = xyes; then |
14 | if $LLVM_CONFIG --components | grep -q '\<mcjit\>'; then |
15 | LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit" |
16 | fi |
17 | + LLVM_COMPONENTS="${LLVM_COMPONENTS} all-targets" |
18 | if test "x$enable_opencl" = xyes; then |
19 | LLVM_COMPONENTS="${LLVM_COMPONENTS} ipo linker instrumentation" |
20 | fi |
21 | @@ -1782,6 +1783,23 @@ gallium_require_drm_loader() { |
22 | fi |
23 | } |
24 | |
25 | +radeon_llvm_check() { |
26 | + LLVM_VERSION_MAJOR=`echo $LLVM_VERSION | cut -d. -f1` |
27 | + if test "$LLVM_VERSION_MAJOR" -lt "3" -o "x$LLVM_VERSION" = "x3.0"; then |
28 | + AC_MSG_ERROR([LLVM 3.1 or newer is required for the r600/radeonsi llvm compiler.]) |
29 | + fi |
30 | + if test "$LLVM_VERSION_MAJOR" -ge "3" -a "x$LLVM_VERSION" != "x3.1" && $LLVM_CONFIG --targets-built | grep -qv '\<AMDGPU\>' ; then |
31 | + AC_MSG_ERROR([To use the r600/radeonsi LLVM backend with LLVM 3.2 and newer, you need to fetch the LLVM source from: |
32 | + git://people.freedesktop.org/~tstellar/llvm master |
33 | + and build with --enable-experimental-targets==AMDGPU]) |
34 | + fi |
35 | + if test "$LLVM_VERSION" = "3.2"; then |
36 | + dnl LLVM 3.2 does not add experimental libraries to llvm-config's |
37 | + dnl library list. |
38 | + LLVM_LIBS="$LLVM_LIBS -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUInfo `$LLVM_CONFIG --libs mc`" |
39 | + fi |
40 | +} |
41 | + |
42 | dnl Gallium drivers |
43 | dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block |
44 | if test "x$with_gallium_drivers" != x; then |
45 | @@ -1812,9 +1830,7 @@ if test "x$with_gallium_drivers" != x; then |
46 | gallium_require_drm_loader |
47 | GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600" |
48 | if test "x$enable_r600_llvm" = xyes -o "x$enable_opencl" = xyes; then |
49 | - if test "x$LLVM_VERSION" != "x3.1"; then |
50 | - AC_MSG_ERROR([LLVM 3.1 is required for the r600 llvm compiler.]) |
51 | - fi |
52 | + radeon_llvm_check |
53 | NEED_RADEON_GALLIUM=yes; |
54 | fi |
55 | if test "x$enable_r600_llvm" = xyes; then |
56 | @@ -1829,9 +1845,7 @@ if test "x$with_gallium_drivers" != x; then |
57 | PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED]) |
58 | gallium_require_drm_loader |
59 | GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS radeonsi" |
60 | - if test "x$LLVM_VERSION" != "x3.1"; then |
61 | - AC_MSG_ERROR([LLVM 3.1 is required to build the radeonsi driver.]) |
62 | - fi |
63 | + radeon_llvm_check |
64 | NEED_RADEON_GALLIUM=yes; |
65 | gallium_check_st "radeon/drm" "dri-radeonsi" "xorg-radeonsi" "" "" "vdpau-radeonsi" "" |
66 | ;; |
67 | diff --git a/src/gallium/drivers/radeon/Makefile b/src/gallium/drivers/radeon/Makefile |
68 | index 7f1c613..bcc2646 100644 |
69 | --- a/src/gallium/drivers/radeon/Makefile |
70 | +++ b/src/gallium/drivers/radeon/Makefile |
71 | @@ -12,6 +12,12 @@ TBLGEN = $(LLVM_BINDIR)/llvm-tblgen |
72 | |
73 | CXXFLAGS+= $(LLVM_CXXFLAGS) |
74 | |
75 | +ifeq ($(LLVM_VERSION),3.1) |
76 | + CPP_SOURCES += $(LLVM_CPP_SOURCES) |
77 | +else |
78 | + CXXFLAGS+= -DEXTERNAL_LLVM |
79 | +endif |
80 | + |
81 | include ../../Makefile.template |
82 | |
83 | CXXFLAGS := $(filter-out -DDEBUG, $(CXXFLAGS)) |
84 | diff --git a/src/gallium/drivers/radeon/Makefile.sources b/src/gallium/drivers/radeon/Makefile.sources |
85 | index c5d1207..5e79342 100644 |
86 | --- a/src/gallium/drivers/radeon/Makefile.sources |
87 | +++ b/src/gallium/drivers/radeon/Makefile.sources |
88 | @@ -23,8 +23,7 @@ TD_FILES := \ |
89 | SIRegisterInfo.td \ |
90 | SISchedule.td |
91 | |
92 | - |
93 | -GENERATED_SOURCES := \ |
94 | +LLVM_GENERATED_SOURCES := \ |
95 | R600Intrinsics.td \ |
96 | R600RegisterInfo.td \ |
97 | SIRegisterInfo.td \ |
98 | @@ -41,7 +40,7 @@ GENERATED_SOURCES := \ |
99 | AMDGPUGenMCCodeEmitter.inc \ |
100 | AMDGPUGenDFAPacketizer.inc |
101 | |
102 | -CPP_SOURCES := \ |
103 | +LLVM_CPP_SOURCES := \ |
104 | AMDIL7XXDevice.cpp \ |
105 | AMDILCFGStructurizer.cpp \ |
106 | AMDILDevice.cpp \ |
107 | @@ -81,6 +80,8 @@ CPP_SOURCES := \ |
108 | MCTargetDesc/SIMCCodeEmitter.cpp \ |
109 | MCTargetDesc/R600MCCodeEmitter.cpp \ |
110 | TargetInfo/AMDGPUTargetInfo.cpp \ |
111 | + |
112 | +CPP_SOURCES := \ |
113 | radeon_llvm_emit.cpp |
114 | |
115 | C_SOURCES := \ |
116 | diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
117 | index 1b67bfe..625b0b4 100644 |
118 | --- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
119 | +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
120 | @@ -90,6 +90,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes, |
121 | /* XXX: Can we just initialize the AMDGPU target here? */ |
122 | InitializeAllTargets(); |
123 | InitializeAllTargetMCs(); |
124 | + InitializeAllAsmPrinters(); |
125 | #else |
126 | LLVMInitializeAMDGPUTargetInfo(); |
127 | LLVMInitializeAMDGPUTarget(); |
128 | -- |
129 | cgit v0.9.0.2-2-gbebe |
130 | From 67fcb3c2b4ecbd87e465b6c6b316be44811ea116 Mon Sep 17 00:00:00 2001 |
131 | From: Tom Stellard <thomas.stellard@amd.com> |
132 | Date: Mon, 01 Oct 2012 21:00:00 +0000 |
133 | Subject: configure.ac: Use amdgpu component for LLVM 3.2 |
134 | |
135 | The amdgpu component actually does exist. I must have been using an |
136 | older version of llvm-config by accident when I first made this change. |
137 | --- |
138 | diff --git a/configure.ac b/configure.ac |
139 | index 32f412b..0de506d 100644 |
140 | --- a/configure.ac |
141 | +++ b/configure.ac |
142 | @@ -1793,10 +1793,8 @@ radeon_llvm_check() { |
143 | git://people.freedesktop.org/~tstellar/llvm master |
144 | and build with --enable-experimental-targets==AMDGPU]) |
145 | fi |
146 | - if test "$LLVM_VERSION" = "3.2"; then |
147 | - dnl LLVM 3.2 does not add experimental libraries to llvm-config's |
148 | - dnl library list. |
149 | - LLVM_LIBS="$LLVM_LIBS -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUInfo `$LLVM_CONFIG --libs mc`" |
150 | + if test "x$LLVM_VERSION" = "x3.2"; then |
151 | + LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --libs amdgpu`" |
152 | fi |
153 | } |
154 | |
155 | -- |
156 | cgit v0.9.0.2-2-gbebe |
157 | From 4cc530f452436a5304a628d1428ed7f07247a175 Mon Sep 17 00:00:00 2001 |
158 | From: Tom Stellard <thomas.stellard@amd.com> |
159 | Date: Wed, 10 Oct 2012 21:00:13 +0000 |
160 | Subject: radeon/llvm: Fix build with LLVM 3.2 |
161 | |
162 | --- |
163 | diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
164 | index 2f2eb4c..21661a0 100644 |
165 | --- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
166 | +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
167 | @@ -36,13 +36,16 @@ |
168 | #include <llvm/Support/TargetRegistry.h> |
169 | #include <llvm/Support/TargetSelect.h> |
170 | #include <llvm/Support/Threading.h> |
171 | -#include <llvm/Target/TargetData.h> |
172 | #include <llvm/Target/TargetMachine.h> |
173 | - |
174 | #include <llvm/Transforms/Scalar.h> |
175 | - |
176 | #include <llvm-c/Target.h> |
177 | |
178 | +#if HAVE_LLVM < 0x0302 |
179 | +#include <llvm/Target/TargetData.h> |
180 | +#else |
181 | +#include <llvm/DataLayout.h> |
182 | +#endif |
183 | + |
184 | #include <iostream> |
185 | #include <stdlib.h> |
186 | #include <stdio.h> |
187 | @@ -120,7 +123,11 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes, |
188 | )); |
189 | TargetMachine &AMDGPUTargetMachine = *tm.get(); |
190 | PassManager PM; |
191 | +#if HAVE_LLVM < 0x0302 |
192 | PM.add(new TargetData(*AMDGPUTargetMachine.getTargetData())); |
193 | +#else |
194 | + PM.add(new DataLayout(*AMDGPUTargetMachine.getDataLayout())); |
195 | +#endif |
196 | PM.add(createPromoteMemoryToRegisterPass()); |
197 | AMDGPUTargetMachine.setAsmVerbosityDefault(true); |
198 | |
199 | -- |
200 | cgit v0.9.0.2-2-gbebe |
201 | From b21455f27db6e55e708f8e264f4a15412ee8fa52 Mon Sep 17 00:00:00 2001 |
202 | From: Dmitry Cherkasov <dcherkassov@gmail.com> |
203 | Date: Wed, 17 Oct 2012 18:03:13 +0000 |
204 | Subject: configure.ac: Fix LLVM 3.2 r600/radeonsi error message |
205 | |
206 | Reviewed-by: Tom Stellard <thomas.stellard@amd.com> |
207 | Signed-off-by: Dmitry Cherkasov <Dmitrii.Cherkasov@amd.com> |
208 | --- |
209 | diff --git a/configure.ac b/configure.ac |
210 | index aefa142..ca24856 100644 |
211 | --- a/configure.ac |
212 | +++ b/configure.ac |
213 | @@ -1757,7 +1757,7 @@ radeon_llvm_check() { |
214 | if test "$LLVM_VERSION_MAJOR" -ge "3" -a "x$LLVM_VERSION" != "x3.1" && $LLVM_CONFIG --targets-built | grep -qv '\<AMDGPU\>' ; then |
215 | AC_MSG_ERROR([To use the r600/radeonsi LLVM backend with LLVM 3.2 and newer, you need to fetch the LLVM source from: |
216 | git://people.freedesktop.org/~tstellar/llvm master |
217 | - and build with --enable-experimental-targets==AMDGPU]) |
218 | + and build with --enable-experimental-targets=AMDGPU]) |
219 | fi |
220 | if test "x$LLVM_VERSION" = "x3.2"; then |
221 | LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --libs amdgpu`" |
222 | -- |
223 | cgit v0.9.0.2-2-gbebe |
224 | From d2b0338e3354fadc90a3751520f4aa44ba01954f Mon Sep 17 00:00:00 2001 |
225 | From: Tom Stellard <thomas.stellard@amd.com> |
226 | Date: Wed, 17 Oct 2012 19:21:48 +0000 |
227 | Subject: r600g: Remove special handling of PRED_SET* insructions for LLVM 3.2 |
228 | |
229 | The 3.2 version of the backend now sets all the correct fields for |
230 | PRED_SET* instructions. |
231 | --- |
232 | diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c |
233 | index 053a988..58b7fb2 100644 |
234 | --- a/src/gallium/drivers/r600/r600_shader.c |
235 | +++ b/src/gallium/drivers/r600/r600_shader.c |
236 | @@ -330,6 +330,7 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx, |
237 | alu.src[src_idx].sel += 512; |
238 | } |
239 | |
240 | +#if HAVE_LLVM < 0x0302 |
241 | if (alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE) || |
242 | alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE) || |
243 | alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT) || |
244 | @@ -340,6 +341,7 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx, |
245 | alu.src[1].chan = 0; |
246 | alu.last = 1; |
247 | } |
248 | +#endif |
249 | |
250 | if (alu.execute_mask) { |
251 | alu.pred_sel = 0; |
252 | -- |
253 | cgit v0.9.0.2-2-gbebe |
254 | From f2f17fc348c847bbf5c54bb75b76e1661e8ced60 Mon Sep 17 00:00:00 2001 |
255 | From: Tom Stellard <thomas.stellard@amd.com> |
256 | Date: Mon, 01 Oct 2012 21:01:06 +0000 |
257 | Subject: radeon/llvm: Only initialize the AMDGPU target |
258 | |
259 | --- |
260 | diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
261 | index 625b0b4..2f2eb4c 100644 |
262 | --- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
263 | +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp |
264 | @@ -86,17 +86,11 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes, |
265 | |
266 | Triple AMDGPUTriple(sys::getDefaultTargetTriple()); |
267 | |
268 | -#ifdef EXTERNAL_LLVM |
269 | - /* XXX: Can we just initialize the AMDGPU target here? */ |
270 | - InitializeAllTargets(); |
271 | - InitializeAllTargetMCs(); |
272 | - InitializeAllAsmPrinters(); |
273 | -#else |
274 | LLVMInitializeAMDGPUTargetInfo(); |
275 | LLVMInitializeAMDGPUTarget(); |
276 | LLVMInitializeAMDGPUTargetMC(); |
277 | LLVMInitializeAMDGPUAsmPrinter(); |
278 | -#endif |
279 | + |
280 | std::string err; |
281 | const Target * AMDGPUTarget = TargetRegistry::lookupTarget("r600", err); |
282 | if(!AMDGPUTarget) { |
283 | -- |
284 | cgit v0.9.0.2-2-gbebe |