]> git.pld-linux.org Git - packages/Mesa.git/blob - Mesa-llvm3.2-support.patch
- drop duplicate backslashes
[packages/Mesa.git] / Mesa-llvm3.2-support.patch
1 From: Tom Stellard <thomas.stell...@amd.com>
2
3 LLVM 3.2 and newer requires that the R600/SI backend be part of the
4 LLVM tree.
5 ---
6  configure.ac                                    | 26 +++++++++++++++++++------
7  src/gallium/drivers/radeon/Makefile             |  6 ++++++
8  src/gallium/drivers/radeon/Makefile.sources     |  7 ++++---
9  src/gallium/drivers/radeon/radeon_llvm_emit.cpp |  1 +
10  4 files changed, 31 insertions(+), 9 deletions(-)</pre><pre>
11
12 diff --git a/configure.ac b/configure.ac
13 index b83078f..a942621 100644
14 --- a/configure.ac
15 +++ b/configure.ac
16 @@ -1667,6 +1667,7 @@
17              if $LLVM_CONFIG --components | grep -q '\<mcjit\>'; then
18                  LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit"
19              fi
20 +            LLVM_COMPONENTS="${LLVM_COMPONENTS} all-targets"
21              if test "x$enable_opencl" = xyes; then
22                  LLVM_COMPONENTS="${LLVM_COMPONENTS} ipo linker instrumentation"
23              fi
24 @@ -1788,6 +1789,23 @@
25      fi
26  }
27  
28 +radeon_llvm_check() {
29 +    LLVM_VERSION_MAJOR=`echo $LLVM_VERSION | cut -d. -f1`
30 +    if test "$LLVM_VERSION_MAJOR" -lt "3" -o "x$LLVM_VERSION" = "x3.0"; then
31 +        AC_MSG_ERROR([LLVM 3.1 or newer is required for the r600/radeonsi llvm compiler.])
32 +    fi
33 +    if test "$LLVM_VERSION_MAJOR" -ge "3" -a "x$LLVM_VERSION" != "x3.1" && $LLVM_CONFIG --targets-built | grep -qv '\<AMDGPU\>' ; then
34 +        AC_MSG_ERROR([To use the r600/radeonsi LLVM backend with LLVM 3.2 and newer, you need to fetch the LLVM source from:
35 +                      git://people.freedesktop.org/~tstellar/llvm master
36 +                      and build with --enable-experimental-targets==AMDGPU])
37 +    fi
38 +    if test "$LLVM_VERSION" = "3.2"; then
39 +        dnl LLVM 3.2 does not add experimental libraries to llvm-config's
40 +        dnl library list.
41 +        LLVM_LIBS="$LLVM_LIBS -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUInfo `$LLVM_CONFIG --libs mc`"
42 +    fi
43 +}
44 +
45  dnl Gallium drivers
46  dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block
47  if test "x$with_gallium_drivers" != x; then
48 @@ -1818,9 +1836,7 @@
49              gallium_require_drm_loader
50              GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
51              if test "x$enable_r600_llvm" = xyes -o "x$enable_opencl" = xyes; then
52 -                if test "x$LLVM_VERSION" != "x3.1"; then
53 -                    AC_MSG_ERROR([LLVM 3.1 is required for the r600 llvm compiler.])
54 -                fi
55 +                radeon_llvm_check
56                  NEED_RADEON_GALLIUM=yes;
57              fi
58              if test "x$enable_r600_llvm" = xyes; then
59 @@ -1835,9 +1851,7 @@
60              PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
61              gallium_require_drm_loader
62              GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS radeonsi"
63 -            if test "x$LLVM_VERSION" != "x3.1"; then
64 -                AC_MSG_ERROR([LLVM 3.1 is required to build the radeonsi driver.])
65 -            fi
66 +           radeon_llvm_check
67             NEED_RADEON_GALLIUM=yes;
68              gallium_check_st "radeon/drm" "dri-radeonsi" "xorg-radeonsi" "" "" "vdpau-radeonsi" ""
69              ;;
70 diff --git a/src/gallium/drivers/radeon/Makefile b/src/gallium/drivers/radeon/Makefile
71 index 7f1c613..bcc2646 100644
72 --- a/src/gallium/drivers/radeon/Makefile
73 +++ b/src/gallium/drivers/radeon/Makefile
74 @@ -12,6 +12,12 @@ TBLGEN = $(LLVM_BINDIR)/llvm-tblgen
75  
76  CXXFLAGS+= $(LLVM_CXXFLAGS)
77  
78 +ifeq ($(LLVM_VERSION),3.1)
79 +       CPP_SOURCES += $(LLVM_CPP_SOURCES)
80 +else
81 +       CXXFLAGS+= -DEXTERNAL_LLVM
82 +endif
83 +
84  include ../../Makefile.template
85  
86  CXXFLAGS := $(filter-out -DDEBUG, $(CXXFLAGS))
87 diff --git a/src/gallium/drivers/radeon/Makefile.sources b/src/gallium/drivers/radeon/Makefile.sources
88 index c5d1207..5e79342 100644
89 --- a/src/gallium/drivers/radeon/Makefile.sources
90 +++ b/src/gallium/drivers/radeon/Makefile.sources
91 @@ -24,7 +24,7 @@
92         SISchedule.td
93  
94  
95 -GENERATED_SOURCES := \
96 +LLVM_GENERATED_SOURCES := \
97         R600Intrinsics.td               \
98         R600RegisterInfo.td             \
99         SIRegisterInfo.td               \
100 @@ -41,7 +41,7 @@
101         AMDGPUGenMCCodeEmitter.inc      \
102         AMDGPUGenDFAPacketizer.inc
103  
104 -CPP_SOURCES := \
105 +LLVM_CPP_SOURCES := \
106         AMDIL7XXDevice.cpp              \
107         AMDILCFGStructurizer.cpp        \
108         AMDILDevice.cpp                 \
109 @@ -80,6 +80,8 @@
110         MCTargetDesc/SIMCCodeEmitter.cpp \
111         MCTargetDesc/R600MCCodeEmitter.cpp \
112         TargetInfo/AMDGPUTargetInfo.cpp \
113 +
114 +CPP_SOURCES := \
115         radeon_llvm_emit.cpp
116  
117  C_SOURCES := \
118 diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
119 index 1b67bfe..625b0b4 100644
120 --- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
121 +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
122 @@ -90,6 +90,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
123     /* XXX: Can we just initialize the AMDGPU target here? */
124     InitializeAllTargets();
125     InitializeAllTargetMCs();
126 +   InitializeAllAsmPrinters();
127  #else
128     LLVMInitializeAMDGPUTargetInfo();
129     LLVMInitializeAMDGPUTarget();
130 -- 
131 1.7.11.4
132 Adjusted hacks for R600 rename
133
134 ---
135  configure.ac                                    | 12 ++++++------
136  src/gallium/drivers/radeon/radeon_llvm_emit.cpp |  7 +++++++
137  2 files changed, 13 insertions(+), 6 deletions(-)
138
139 diff --git a/configure.ac b/configure.ac
140 index 228f464..b848503 100644
141 --- a/configure.ac
142 +++ b/configure.ac
143 @@ -1794,15 +1794,15 @@
144      if test "$LLVM_VERSION_MAJOR" -lt "3" -o "x$LLVM_VERSION" = "x3.0"; then
145          AC_MSG_ERROR([LLVM 3.1 or newer is required for the r600/radeonsi llvm compiler.])
146      fi
147 -    if test "$LLVM_VERSION_MAJOR" -ge "3" -a "x$LLVM_VERSION" != "x3.1" && $LLVM_CONFIG --targets-built | grep -qv '\<AMDGPU\>' ; then
148 +    if test "$LLVM_VERSION_MAJOR" -ge "3" -a "x$LLVM_VERSION" != "x3.1" && $LLVM_CONFIG --targets-built | grep -qv '\<R600\>' ; then
149          AC_MSG_ERROR([To use the r600/radeonsi LLVM backend with LLVM 3.2 and newer, you need to fetch the LLVM source from:
150                        git://people.freedesktop.org/~tstellar/llvm master
151 -                      and build with --enable-experimental-targets==AMDGPU])
152 +                      and build with --enable-experimental-targets=R600])
153      fi
154      if test "$LLVM_VERSION" = "3.2"; then
155          dnl LLVM 3.2 does not add experimental libraries to llvm-config's
156          dnl library list.
157 -        LLVM_LIBS="$LLVM_LIBS -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUInfo `$LLVM_CONFIG --libs mc`"
158 +        LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --libs R600`"
159      fi
160  }
161  
162 diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
163 index 21661a0..9914228 100644
164 --- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
165 +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
166 @@ -86,17 +86,11 @@
167  
168     Triple AMDGPUTriple(sys::getDefaultTargetTriple());
169  
170 -#ifdef EXTERNAL_LLVM
171 -   /* XXX: Can we just initialize the AMDGPU target here? */
172 -   InitializeAllTargets();
173 -   InitializeAllTargetMCs();
174 -   InitializeAllAsmPrinters();
175 -#else
176 -   LLVMInitializeAMDGPUTargetInfo();
177 -   LLVMInitializeAMDGPUTarget();
178 -   LLVMInitializeAMDGPUTargetMC();
179 -   LLVMInitializeAMDGPUAsmPrinter();
180 -#endif
181 +   LLVMInitializeR600TargetInfo();
182 +   LLVMInitializeR600Target();
183 +   LLVMInitializeR600TargetMC();
184 +   LLVMInitializeR600AsmPrinter();
185 +
186     std::string err;
187     const Target * AMDGPUTarget = TargetRegistry::lookupTarget("r600", err);
188     if(!AMDGPUTarget) {
189 -- 
190 1.7.11.4
191 --- Mesa-9.0.2/src/gallium/drivers/radeon/radeon_llvm_emit.cpp.orig     2013-01-25 22:40:57.939828359 +0100
192 +++ Mesa-9.0.2/src/gallium/drivers/radeon/radeon_llvm_emit.cpp  2013-01-26 07:58:59.045797173 +0100
193 @@ -36,12 +36,14 @@
194  #include <llvm/Support/TargetRegistry.h>
195  #include <llvm/Support/TargetSelect.h>
196  #include <llvm/Support/Threading.h>
197 -#include <llvm/Target/TargetData.h>
198  #include <llvm/Target/TargetMachine.h>
199 -
200  #include <llvm/Transforms/Scalar.h>
201 -
202  #include <llvm-c/Target.h>
203 +#if HAVE_LLVM < 0x0302
204 +#include <llvm/Target/TargetData.h>
205 +#else
206 +#include <llvm/DataLayout.h>
207 +#endif
208  
209  #include <iostream>
210  #include <stdlib.h>
211 @@ -120,7 +122,11 @@
212                       ));
213     TargetMachine &AMDGPUTargetMachine = *tm.get();
214     PassManager PM;
215 +#if HAVE_LLVM < 0x0302
216     PM.add(new TargetData(*AMDGPUTargetMachine.getTargetData()));
217 +#else
218 +   PM.add(new DataLayout(*AMDGPUTargetMachine.getDataLayout()));
219 +#endif
220     PM.add(createPromoteMemoryToRegisterPass());
221     AMDGPUTargetMachine.setAsmVerbosityDefault(true);
222  
223 --- Mesa-9.0.2/src/gallium/state_trackers/clover/llvm/invocation.cpp.orig       2013-01-22 19:09:32.000000000 +0100
224 +++ Mesa-9.0.2/src/gallium/state_trackers/clover/llvm/invocation.cpp    2013-01-26 08:53:17.405729259 +0100
225 @@ -35,9 +35,13 @@
226  #include <llvm/Support/TargetSelect.h>
227  #include <llvm/Support/MemoryBuffer.h>
228  #include <llvm/Support/PathV1.h>
229 -#include <llvm/Target/TargetData.h>
230  #include <llvm/Transforms/IPO.h>
231  #include <llvm/Transforms/IPO/PassManagerBuilder.h>
232 +#if HAVE_LLVM < 0x0302
233 +#include <llvm/Target/TargetData.h>
234 +#else
235 +#include <llvm/DataLayout.h>
236 +#endif
237  
238  #include "pipe/p_state.h"
239  #include "util/u_memory.h"
240 @@ -120,9 +124,19 @@
241  
242        c.getLangOpts().NoBuiltin = true;
243        c.getTargetOpts().Triple = triple;
244 +#if HAVE_LLVM < 0x0302
245        c.getInvocation().setLangDefaults(clang::IK_OpenCL);
246 +#else
247 +      c.getInvocation().setLangDefaults(c.getLangOpts(), clang::IK_OpenCL, clang::LangStandard::lang_opencl11);
248 +#endif
249        c.createDiagnostics(0, NULL, new clang::TextDiagnosticPrinter(
250 -                          s_log, c.getDiagnosticOpts()));
251 +                          s_log,
252 +#if HAVE_LLVM < 0x0302
253 +                         c.getDiagnosticOpts()
254 +#else
255 +                         &c.getDiagnosticOpts()
256 +#endif
257 +                         ));
258  
259        c.getPreprocessorOpts().addRemappedFile(name,
260                                        llvm::MemoryBuffer::getMemBuffer(source));
261 @@ -213,7 +227,11 @@
262                                     E = kernel_func->arg_end(); I != E; ++I) {
263           llvm::Argument &arg = *I;
264           llvm::Type *arg_type = arg.getType();
265 +#if HAVE_LLVM < 0x0302
266           llvm::TargetData TD(kernel_func->getParent());
267 +#else
268 +         llvm::DataLayout TD(kernel_func->getParent()->getDataLayout());
269 +#endif
270           unsigned arg_size = TD.getTypeStoreSize(arg_type);
271  
272           if (llvm::isa<llvm::PointerType>(arg_type) && arg.hasByValAttr()) {
273 --- Mesa-9.0.2/src/gallium/targets/opencl/Makefile.am.orig      2013-01-22 19:09:32.000000000 +0100
274 +++ Mesa-9.0.2/src/gallium/targets/opencl/Makefile.am   2013-01-26 09:32:36.189013426 +0100
275 @@ -20,7 +20,6 @@
276         -lclangParse \
277         -lclangSema \
278         -lclangAnalysis \
279 -       -lclangRewrite \
280         -lclangAST \
281         -lclangLex \
282         -lclangBasic \
This page took 0.044857 seconds and 3 git commands to generate.