[Mesa-dev] [PATCH 2/4] meson: Add support for ppc assembly/optimizations

Dylan Baker dylan at pnwbakers.com
Thu Jun 7 18:53:07 UTC 2018


---
 meson.build       | 30 ++++++++++++++++++++++++++----
 meson_options.txt |  7 +++++++
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/meson.build b/meson.build
index 0171328bcd7..f6fe141056a 100644
--- a/meson.build
+++ b/meson.build
@@ -601,13 +601,33 @@ if with_gallium_st_nine
   endif
 endif
 
+if get_option('altivec') != 'false'
+  if host_machine.cpu_family() == 'ppc64le'
+    if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8')
+      error('Altivec is not supported with gcc version < 4.8.')
+    endif
+    if cc.compiles('''
+        #include <altivec.h>
+        int main() {
+          vector unsigned char r;
+          vector unsigned int v = vec_splat_u32 (1);
+          r = __builtin_vec_vgbbd ((vector unsigned char) v);
+          return 0;
+        }''',
+        name : 'POWER8 intrinsics')
+      pre_args += ['-D_ARCH_PWR8', '-mpower8-vector']
+    elif get_option('altivec') == 'true'
+      error('Altivec support required but not found.')
+    endif
+  endif
+endif
+
 _opencl = get_option('gallium-opencl')
 if _opencl != 'disabled'
   if not with_gallium
     error('OpenCL Clover implementation requires at least one gallium driver.')
   endif
 
-  # TODO: alitvec?
   dep_clc = dependency('libclc')
   with_gallium_opencl = true
   with_opencl_icd = _opencl == 'icd'
@@ -837,8 +857,6 @@ if not cc.links('''#include <stdint.h>
   pre_args += '-DMISSING_64_BIT_ATOMICS'
 endif
 
-# TODO: endian
-# TODO: powr8
 # TODO: shared/static? Is this even worth doing?
 
 # When cross compiling we generally need to turn off the use of assembly,
@@ -865,7 +883,6 @@ endif
 
 with_asm_arch = ''
 if with_asm
-  # TODO: SPARC and PPC
   if host_machine.cpu_family() == 'x86'
     if system_has_kms_drm
       with_asm_arch = 'x86'
@@ -892,6 +909,11 @@ if with_asm
       with_asm_arch = 'sparc'
       pre_args += ['-DUSE_SPARC_ASM']
     endif
+  elif host_machine.cpu_family() == 'ppc64le'
+    if system_has_kms_drm
+      with_asm_arch = 'ppc64le'
+      pre_args += ['-DUSE_PPC64LE_ASM']
+    endif
   endif
 endif
 
diff --git a/meson_options.txt b/meson_options.txt
index 2c1f514debe..5976e14fc71 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -298,3 +298,10 @@ option(
   choices : ['freedreno', 'glsl', 'intel', 'nir', 'nouveau', 'all'],
   description : 'List of tools to build.',
 )
+option(
+  'altivec',
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false'],
+  description : 'Enable altivec optimizations if supported by host machine.',
+)
-- 
2.17.1



More information about the mesa-dev mailing list