Mesa (master): radeon: Support LLVM 3.2

Tom Stellard tstellar at kemper.freedesktop.org
Mon Oct 1 16:11:48 UTC 2012


Module: Mesa
Branch: master
Commit: 8d9778589f4b3a174e884338adb0fe1bdeca5eb7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d9778589f4b3a174e884338adb0fe1bdeca5eb7

Author: Tom Stellard <thomas.stellard at amd.com>
Date:   Thu May 10 10:21:54 2012 -0400

radeon: Support LLVM 3.2

LLVM 3.2 and newer requires that the R600/SI backend be part of the
LLVM tree.

---

 configure.ac                                    |   26 +++++++++++++++++-----
 src/gallium/drivers/radeon/Makefile             |    6 +++++
 src/gallium/drivers/radeon/Makefile.sources     |    7 +++--
 src/gallium/drivers/radeon/radeon_llvm_emit.cpp |    1 +
 4 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 896f98a..32f412b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1661,6 +1661,7 @@ if test "x$enable_gallium_llvm" = xyes; then
             if $LLVM_CONFIG --components | grep -q '\<mcjit\>'; then
                 LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit"
             fi
+            LLVM_COMPONENTS="${LLVM_COMPONENTS} all-targets"
             if test "x$enable_opencl" = xyes; then
                 LLVM_COMPONENTS="${LLVM_COMPONENTS} ipo linker instrumentation"
             fi
@@ -1782,6 +1783,23 @@ gallium_require_drm_loader() {
     fi
 }
 
+radeon_llvm_check() {
+    LLVM_VERSION_MAJOR=`echo $LLVM_VERSION | cut -d. -f1`
+    if test "$LLVM_VERSION_MAJOR" -lt "3" -o "x$LLVM_VERSION" = "x3.0"; then
+        AC_MSG_ERROR([LLVM 3.1 or newer is required for the r600/radeonsi llvm compiler.])
+    fi
+    if test "$LLVM_VERSION_MAJOR" -ge "3" -a "x$LLVM_VERSION" != "x3.1" && $LLVM_CONFIG --targets-built | grep -qv '\<AMDGPU\>' ; then
+        AC_MSG_ERROR([To use the r600/radeonsi LLVM backend with LLVM 3.2 and newer, you need to fetch the LLVM source from:
+                      git://people.freedesktop.org/~tstellar/llvm master
+                      and build with --enable-experimental-targets==AMDGPU])
+    fi
+    if test "$LLVM_VERSION" = "3.2"; then
+        dnl LLVM 3.2 does not add experimental libraries to llvm-config's
+        dnl library list.
+        LLVM_LIBS="$LLVM_LIBS -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUInfo `$LLVM_CONFIG --libs mc`"
+    fi
+}
+
 dnl Gallium drivers
 dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block
 if test "x$with_gallium_drivers" != x; then
@@ -1812,9 +1830,7 @@ if test "x$with_gallium_drivers" != x; then
             gallium_require_drm_loader
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
             if test "x$enable_r600_llvm" = xyes -o "x$enable_opencl" = xyes; then
-                if test "x$LLVM_VERSION" != "x3.1"; then
-                    AC_MSG_ERROR([LLVM 3.1 is required for the r600 llvm compiler.])
-                fi
+                radeon_llvm_check
                 NEED_RADEON_GALLIUM=yes;
             fi
             if test "x$enable_r600_llvm" = xyes; then
@@ -1829,9 +1845,7 @@ if test "x$with_gallium_drivers" != x; then
             PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
             gallium_require_drm_loader
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS radeonsi"
-            if test "x$LLVM_VERSION" != "x3.1"; then
-                AC_MSG_ERROR([LLVM 3.1 is required to build the radeonsi driver.])
-            fi
+            radeon_llvm_check
 	    NEED_RADEON_GALLIUM=yes;
             gallium_check_st "radeon/drm" "dri-radeonsi" "xorg-radeonsi" "" "" "vdpau-radeonsi" ""
             ;;
diff --git a/src/gallium/drivers/radeon/Makefile b/src/gallium/drivers/radeon/Makefile
index 7f1c613..bcc2646 100644
--- a/src/gallium/drivers/radeon/Makefile
+++ b/src/gallium/drivers/radeon/Makefile
@@ -12,6 +12,12 @@ TBLGEN = $(LLVM_BINDIR)/llvm-tblgen
 
 CXXFLAGS+= $(LLVM_CXXFLAGS)
 
+ifeq ($(LLVM_VERSION),3.1)
+	CPP_SOURCES += $(LLVM_CPP_SOURCES)
+else
+	CXXFLAGS+= -DEXTERNAL_LLVM
+endif
+
 include ../../Makefile.template
 
 CXXFLAGS := $(filter-out -DDEBUG, $(CXXFLAGS))
diff --git a/src/gallium/drivers/radeon/Makefile.sources b/src/gallium/drivers/radeon/Makefile.sources
index c5d1207..5e79342 100644
--- a/src/gallium/drivers/radeon/Makefile.sources
+++ b/src/gallium/drivers/radeon/Makefile.sources
@@ -23,8 +23,7 @@ TD_FILES := \
 	SIRegisterInfo.td	\
 	SISchedule.td
 
-
-GENERATED_SOURCES := \
+LLVM_GENERATED_SOURCES := \
 	R600Intrinsics.td		\
 	R600RegisterInfo.td		\
 	SIRegisterInfo.td		\
@@ -41,7 +40,7 @@ GENERATED_SOURCES := \
 	AMDGPUGenMCCodeEmitter.inc	\
 	AMDGPUGenDFAPacketizer.inc
 
-CPP_SOURCES := \
+LLVM_CPP_SOURCES := \
 	AMDIL7XXDevice.cpp		\
 	AMDILCFGStructurizer.cpp	\
 	AMDILDevice.cpp			\
@@ -81,6 +80,8 @@ CPP_SOURCES := \
 	MCTargetDesc/SIMCCodeEmitter.cpp \
 	MCTargetDesc/R600MCCodeEmitter.cpp \
 	TargetInfo/AMDGPUTargetInfo.cpp	\
+
+CPP_SOURCES := \
 	radeon_llvm_emit.cpp
 
 C_SOURCES := \
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
index 1b67bfe..625b0b4 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
@@ -90,6 +90,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
    /* XXX: Can we just initialize the AMDGPU target here? */
    InitializeAllTargets();
    InitializeAllTargetMCs();
+   InitializeAllAsmPrinters();
 #else
    LLVMInitializeAMDGPUTargetInfo();
    LLVMInitializeAMDGPUTarget();




More information about the mesa-commit mailing list