Hi all, This patch adds PPC Altivec support for pack/unpack operations using Altivec supported vector type (8xi8, 16xi16, 4xi32, 4xf32). I focused my work on the lp_test_conv testcase for llvmpipe and this patch corrects all the failing issues for conversion using the aforementioned vector types.
I wasn't sure which code styling to use, so I tried to guess based on the current style of the file. Any advices, tips, suggestions?
>From c1994479a2fad9b869fd862d5020bb867911ea1b Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella <[email protected]> Date: Mon, 5 Nov 2012 11:33:42 -0600 Subject: [PATCH] PowerPC: Add Altivec pack/unpack intrisics This patch adds PPC Altivec support for pack/unpack operations using Altivec supported vector type (8xi8, 16xi16, 4xi32, 4xf32). --- src/gallium/auxiliary/gallivm/lp_bld_pack.c | 44 ++++++++++++++++++-------- 1 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c b/src/gallium/auxiliary/gallivm/lp_bld_pack.c index b18f784..4751742 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c @@ -397,30 +397,46 @@ lp_build_pack2(struct gallivm_state *gallivm, assert(src_type.length * 2 == dst_type.length); /* Check for special cases first */ - if(util_cpu_caps.has_sse2 && src_type.width * src_type.length >= 128) { + if((util_cpu_caps.has_sse2 || util_cpu_caps.has_altivec) && + src_type.width * src_type.length >= 128) { const char *intrinsic = NULL; switch(src_type.width) { case 32: - if(dst_type.sign) { - intrinsic = "llvm.x86.sse2.packssdw.128"; - } - else { - if (util_cpu_caps.has_sse4_1) { - intrinsic = "llvm.x86.sse41.packusdw"; + if (util_cpu_caps.has_sse2) { + if(dst_type.sign) { + intrinsic = "llvm.x86.sse2.packssdw.128"; + } + else { + if (util_cpu_caps.has_sse4_1) { + intrinsic = "llvm.x86.sse41.packusdw"; #if HAVE_LLVM < 0x0207 - /* llvm < 2.7 has inconsistent signatures except for packusdw */ - intr_type = dst_type; + /* llvm < 2.7 has inconsistent signatures except for packusdw */ + intr_type = dst_type; #endif - } + } + } + } else if (util_cpu_caps.has_altivec) { + if (dst_type.sign) { + intrinsic = "llvm.ppc.altivec.vpkswus"; + } else { + intrinsic = "llvm.ppc.altivec.vpkuwus"; + } } break; case 16: if (dst_type.sign) { - intrinsic = "llvm.x86.sse2.packsswb.128"; - } - else { - intrinsic = "llvm.x86.sse2.packuswb.128"; + if (util_cpu_caps.has_sse2) { + intrinsic = "llvm.x86.sse2.packsswb.128"; + } else if (util_cpu_caps.has_altivec) { + intrinsic = "llvm.ppc.altivec.vpkshss"; + } + } else { + if (util_cpu_caps.has_sse2) { + intrinsic = "llvm.x86.sse2.packuswb.128"; + } else if (util_cpu_caps.has_altivec) { + intrinsic = "llvm.ppc.altivec.vpkshus"; + } } break; /* default uses generic shuffle below */ -- 1.7.1
_______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
