From 05dd12b9a50ee2eaf768260c6ad8f859afd434de Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 21 Jun 2024 12:13:42 +1000 Subject: [PATCH] gallivm: move ppc denorm disable to inline This just puts it out of the way Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 22 +--------------- src/gallium/auxiliary/gallivm/lp_bld_init.h | 28 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 38daf0bc9dc..341f9349990 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -358,27 +358,7 @@ lp_build_init(void) lp_set_target_options(); -#if DETECT_ARCH_PPC_64 - /* Set the NJ bit in VSCR to 0 so denormalized values are handled as - * specified by IEEE standard (PowerISA 2.06 - Section 6.3). This guarantees - * that some rounding and half-float to float handling does not round - * incorrectly to 0. - * XXX: should eventually follow same logic on all platforms. - * Right now denorms get explicitly disabled (but elsewhere) for x86, - * whereas ppc64 explicitly enables them... - */ - if (util_get_cpu_caps()->has_altivec) { - unsigned short mask[] = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, - 0xFFFF, 0xFFFF, 0xFFFE, 0xFFFF }; - __asm ( - "mfvscr %%v1\n" - "vand %0,%%v1,%0\n" - "mtvscr %0" - : - : "r" (*mask) - ); - } -#endif + lp_bld_ppc_disable_denorms(); gallivm_initialized = true; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h index b9ff4b376d0..f74a51c23b7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h @@ -32,6 +32,7 @@ #include "util/compiler.h" #include "util/u_pointer.h" // for func_pointer +#include "util/u_cpu_detect.h" #include "lp_bld.h" #include "lp_bld_passmgr.h" #include @@ -106,6 +107,33 @@ gallivm_jit_function(struct gallivm_state *gallivm, unsigned gallivm_get_perf_flags(void); void lp_init_clock_hook(struct gallivm_state *gallivm); + +static inline void +lp_bld_ppc_disable_denorms(void) +{ +#if DETECT_ARCH_PPC_64 + /* Set the NJ bit in VSCR to 0 so denormalized values are handled as + * specified by IEEE standard (PowerISA 2.06 - Section 6.3). This guarantees + * that some rounding and half-float to float handling does not round + * incorrectly to 0. + * XXX: should eventually follow same logic on all platforms. + * Right now denorms get explicitly disabled (but elsewhere) for x86, + * whereas ppc64 explicitly enables them... + */ + if (util_get_cpu_caps()->has_altivec) { + unsigned short mask[] = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFE, 0xFFFF }; + __asm ( + "mfvscr %%v1\n" + "vand %0,%%v1,%0\n" + "mtvscr %0" + : + : "r" (*mask) + ); + } +#endif +} + #ifdef __cplusplus } #endif