hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/s390/multiarch/ifunc-resolve.h

Packit 6c4009
/* IFUNC resolver function for CPU specific functions.
Packit 6c4009
   32/64 bit S/390 version.
Packit 6c4009
   Copyright (C) 2015-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <unistd.h>
Packit 6c4009
#include <dl-procinfo.h>
Packit 6c4009
Packit 6c4009
#define S390_STFLE_BITS_Z10  34 /* General instructions extension */
Packit 6c4009
#define S390_STFLE_BITS_Z196 45 /* Distinct operands, pop ... */
Packit 6c4009
Packit 6c4009
#define S390_IS_Z196(STFLE_BITS)			\
Packit 6c4009
  ((STFLE_BITS & (1ULL << (63 - S390_STFLE_BITS_Z196))) != 0)
Packit 6c4009
Packit 6c4009
#define S390_IS_Z10(STFLE_BITS)				\
Packit 6c4009
  ((STFLE_BITS & (1ULL << (63 - S390_STFLE_BITS_Z10))) != 0)
Packit 6c4009
Packit 6c4009
#define S390_STORE_STFLE(STFLE_BITS)					\
Packit 6c4009
  /* We want just 1 double word to be returned.  */			\
Packit 6c4009
  register unsigned long reg0 __asm__("0") = 0;				\
Packit 6c4009
									\
Packit 6c4009
  __asm__ __volatile__(".machine push"        "\n\t"			\
Packit 6c4009
		       ".machine \"z9-109\""  "\n\t"			\
Packit 6c4009
		       ".machinemode \"zarch_nohighgprs\"\n\t"		\
Packit 6c4009
		       "stfle %0"             "\n\t"			\
Packit 6c4009
		       ".machine pop"         "\n"			\
Packit 6c4009
		       : "=QS" (STFLE_BITS), "+d" (reg0)		\
Packit 6c4009
		       : : "cc");
Packit 6c4009
#define s390_libc_ifunc_init()						\
Packit 6c4009
  unsigned long long stfle_bits = 0ULL;					\
Packit 12ed5e
  if (__glibc_likely ((hwcap & HWCAP_S390_STFLE)			\
Packit 12ed5e
		      && (hwcap & HWCAP_S390_ZARCH)			\
Packit 12ed5e
		      && (hwcap & HWCAP_S390_HIGH_GPRS)))		\
Packit 6c4009
    {									\
Packit 6c4009
      S390_STORE_STFLE (stfle_bits);					\
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
#define s390_libc_ifunc(TYPE_FUNC, RESOLVERFUNC, FUNC)			\
Packit 6c4009
  /* Make the declarations of the optimized functions hidden in order
Packit 6c4009
     to prevent GOT slots being generated for them. */			\
Packit 6c4009
  extern __typeof (TYPE_FUNC) RESOLVERFUNC##_z196 attribute_hidden;	\
Packit 6c4009
  extern __typeof (TYPE_FUNC) RESOLVERFUNC##_z10 attribute_hidden;      \
Packit 6c4009
  extern __typeof (TYPE_FUNC) RESOLVERFUNC##_default attribute_hidden;  \
Packit 6c4009
  __ifunc (TYPE_FUNC, FUNC,						\
Packit 6c4009
	   __glibc_likely (S390_IS_Z196 (stfle_bits))			\
Packit 6c4009
	   ? RESOLVERFUNC##_z196					\
Packit 6c4009
	   : __glibc_likely (S390_IS_Z10 (stfle_bits))			\
Packit 6c4009
	     ? RESOLVERFUNC##_z10					\
Packit 6c4009
	     : RESOLVERFUNC##_default,					\
Packit 12ed5e
	   unsigned long int hwcap, s390_libc_ifunc_init);
Packit 6c4009
Packit 6c4009
#define s390_vx_libc_ifunc(FUNC)		\
Packit 6c4009
  s390_vx_libc_ifunc2_redirected(FUNC, FUNC, FUNC)
Packit 6c4009
Packit 6c4009
#define s390_vx_libc_ifunc_redirected(TYPE_FUNC, FUNC)	\
Packit 6c4009
  s390_vx_libc_ifunc2_redirected(TYPE_FUNC, FUNC, FUNC)
Packit 6c4009
Packit 6c4009
#define s390_vx_libc_ifunc2(RESOLVERFUNC, FUNC)	\
Packit 6c4009
  s390_vx_libc_ifunc2_redirected(FUNC, RESOLVERFUNC, FUNC)
Packit 6c4009
Packit 6c4009
#define s390_vx_libc_ifunc_init()
Packit 6c4009
#define s390_vx_libc_ifunc2_redirected(TYPE_FUNC, RESOLVERFUNC, FUNC)	\
Packit 6c4009
  /* Make the declarations of the optimized functions hidden in order
Packit 6c4009
     to prevent GOT slots being generated for them.  */			\
Packit 6c4009
  extern __typeof (TYPE_FUNC) RESOLVERFUNC##_vx attribute_hidden;	\
Packit 6c4009
  extern __typeof (TYPE_FUNC) RESOLVERFUNC##_c attribute_hidden;	\
Packit 6c4009
  __ifunc (TYPE_FUNC, FUNC,						\
Packit 12ed5e
	   (hwcap & HWCAP_S390_VX)					\
Packit 6c4009
	   ? RESOLVERFUNC##_vx						\
Packit 6c4009
	   : RESOLVERFUNC##_c,						\
Packit 12ed5e
	   unsigned long int hwcap, s390_vx_libc_ifunc_init);
Packit 6c4009
Packit 6c4009
#define s390_libc_ifunc_expr_init()
Packit 6c4009
#define s390_libc_ifunc_expr(TYPE_FUNC, FUNC, EXPR)		\
Packit 6c4009
  __ifunc (TYPE_FUNC, FUNC, EXPR, unsigned long int hwcap,	\
Packit 6c4009
	   s390_libc_ifunc_expr_init);