comparison src/cpu.c @ 25:92156fe32755

impl/ppc/altivec: update to new implementation the signed average function is wrong; it needs to round up the number when only one of them is odd, but that doesn't necessarily seem to be true because altivec is weird, and that's what we need to emulate the quirks for. ugh. also the altivec backend uses the generic functions instead of fallbacks because it does indeed use the exact same memory structure as the generic implementation...
author Paper <paper@tflc.us>
date Sun, 24 Nov 2024 11:15:59 +0000
parents e26874655738
children
comparison
equal deleted inserted replaced
24:e49e70f7012f 25:92156fe32755
42 * 2. Altered source versions must be plainly marked as such, and must not be 42 * 2. Altered source versions must be plainly marked as such, and must not be
43 * misrepresented as being the original software. 43 * misrepresented as being the original software.
44 * 3. This notice may not be removed or altered from any source distribution. 44 * 3. This notice may not be removed or altered from any source distribution.
45 */ 45 */
46 46
47 #include "vec/vec.h"
47 #include "vec/cpu.h" 48 #include "vec/cpu.h"
48 49
49 #if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__)) 50 #if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
50 # include <sys/sysctl.h> // For AltiVec check 51 # include <sys/sysctl.h> // For AltiVec check
51 #elif defined(__OpenBSD__) && defined(__powerpc__) 52 #elif defined(__OpenBSD__) && defined(__powerpc__)
53 # include <sys/sysctl.h> // For AltiVec check 54 # include <sys/sysctl.h> // For AltiVec check
54 # include <machine/cpu.h> 55 # include <machine/cpu.h>
55 #elif defined(__FreeBSD__) && defined(__powerpc__) 56 #elif defined(__FreeBSD__) && defined(__powerpc__)
56 # include <machine/cpu.h> 57 # include <machine/cpu.h>
57 # include <sys/auxv.h> 58 # include <sys/auxv.h>
58 #elif defined(__ALTIVEC__) 59 #elif defined(VEC_COMPILER_HAS_ALTIVEC)
59 # include <signal.h> 60 # include <signal.h>
60 # include <setjmp.h> 61 # include <setjmp.h>
61 #endif 62 #endif
62 63
63 #ifdef __FreeBSD__ 64 #ifdef __FreeBSD__
308 altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC; 309 altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
309 #elif defined(VEC_COMPILER_HAS_ALTIVEC) && defined(__GNUC__) 310 #elif defined(VEC_COMPILER_HAS_ALTIVEC) && defined(__GNUC__)
310 void (*handler)(int sig); 311 void (*handler)(int sig);
311 handler = signal(SIGILL, vec_CPU_illegal_instruction); 312 handler = signal(SIGILL, vec_CPU_illegal_instruction);
312 if (!setjmp(vec_jmpbuf)) { 313 if (!setjmp(vec_jmpbuf)) {
313 vector unsigned char vec; 314 __asm__ __volatile__("mtspr 256, %0\n\t"
314 vec_and(vec, vec); 315 "vand %%v0, %%v0, %%v0" ::"r"(-1));
315 altivec = 1; 316 altivec = 1;
316 } 317 }
317 signal(SIGILL, handler); 318 signal(SIGILL, handler);
318 #endif 319 #endif
319 return altivec; 320 return altivec;