From patchwork Tue Oct 14 21:51:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Fortune X-Patchwork-Id: 3231 Received: (qmail 25392 invoked by alias); 14 Oct 2014 21:51:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 25317 invoked by uid 89); 14 Oct 2014 21:51:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com From: Matthew Fortune To: "libc-alpha@sourceware.org" CC: "Joseph Myers (joseph@codesourcery.com)" , "Moore, Catherine (Catherine_Moore@mentor.com)" , 'Andrew Pinski' , "Rich Felker (dalias@libc.org)" , Rich Fuhler , "'macro@codesourcery.com'" Subject: [PATCH] Support HWCAPs for MIPS Date: Tue, 14 Oct 2014 21:51:50 +0000 Message-ID: <6D39441BF12EF246A7ABCE6654B0235320F271C0@LEMAIL01.le.imgtec.org> MIME-Version: 1.0 This patch is split out of https://sourceware.org/ml/libc-alpha/2014-10/msg00056.html MIPS is beginning to use HWCAPs and initially R6 and MSA feature bits are being defined. The MSA bit will be used by the O32 FPXX ABI patch. The R6 bit is to support runtime code generation by JITs so that they can avoid trap and emulation of removed instructions in generated code. (A patch to enable GLIBC to be built for R6 will be submitted in due course so that the optimised assembly routines also avoid removed instructions.) Thanks, Matthew * sysdeps/mips/bits/hwcap.h: New file. * sysdeps/mips/dl-procinfo.c (_dl_mips_cap_flags): Declare. * sysdeps/mips/dl-procinfo.h (_DL_HWCAP_COUNT): Define. (HWCAP_IMPORTANT): Define. (_dl_procinfo): New static inline function. (_dl_hwcap_string, _dl_string_hwcap): Likewise. --- sysdeps/mips/bits/hwcap.h | 24 ++++++++++++++++++++++ sysdeps/mips/dl-procinfo.c | 16 +++++++++++++++ sysdeps/mips/dl-procinfo.h | 50 +++++++++++++++++++++++++++++++++++++--------- 3 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 sysdeps/mips/bits/hwcap.h diff --git a/sysdeps/mips/bits/hwcap.h b/sysdeps/mips/bits/hwcap.h new file mode 100644 index 0000000..0013717 --- /dev/null +++ b/sysdeps/mips/bits/hwcap.h @@ -0,0 +1,24 @@ +/* Defines for bits in AT_HWCAP. + Copyright (C) 2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if !defined(_SYS_AUXV_H) && !defined(_SYSDEPS_SYSDEP_H) +# error "Never include directly; use instead." +#endif + +#define HWCAP_MIPS_R6 0x00000001 +#define HWCAP_MIPS_MSA 0x00000002 diff --git a/sysdeps/mips/dl-procinfo.c b/sysdeps/mips/dl-procinfo.c index 4a3dbf3..3e7b7ed 100644 --- a/sysdeps/mips/dl-procinfo.c +++ b/sysdeps/mips/dl-procinfo.c @@ -59,5 +59,21 @@ PROCINFO_CLASS const char _dl_mips_platforms[4][11] , #endif +#if !defined PROCINFO_DECL && defined SHARED + ._dl_mips_cap_flags +#else +PROCINFO_CLASS const char _dl_mips_cap_flags[2][4] +#endif +#ifndef PROCINFO_DECL += { + "r6", "msa" + } +#endif +#if !defined SHARED || defined PROCINFO_DECL +; +#else +, +#endif + #undef PROCINFO_DECL #undef PROCINFO_CLASS diff --git a/sysdeps/mips/dl-procinfo.h b/sysdeps/mips/dl-procinfo.h index b2b7702..3aa236a 100644 --- a/sysdeps/mips/dl-procinfo.h +++ b/sysdeps/mips/dl-procinfo.h @@ -50,18 +50,50 @@ _dl_string_platform (const char *str) return -1; }; -/* We cannot provide a general printing function. */ -#define _dl_procinfo(type, word) -1 +#define _DL_HWCAP_COUNT 2 -/* There are no hardware capabilities defined. */ -#define _dl_hwcap_string(idx) "" +#define HWCAP_IMPORTANT (HWCAP_MIPS_MSA) -/* By default there is no important hardware capability. */ -#define HWCAP_IMPORTANT (0) +static inline int +__attribute__ ((unused)) +_dl_procinfo (unsigned int type, unsigned long int word) +{ + int i; + + /* Fallback to unknown output mechanism. */ + if (type == AT_HWCAP2) + return -1; + + _dl_printf ("AT_HWCAP: "); + + for (i = 0; i < _DL_HWCAP_COUNT; ++i) + if (word & (1 << i)) + _dl_printf (" %s", GLRO(dl_mips_cap_flags)[i]); + + _dl_printf ("\n"); + + return 0; +} + +static inline const char * +__attribute__ ((unused)) +_dl_hwcap_string (int idx) +{ + return GLRO(dl_mips_cap_flags)[idx]; +}; -/* We don't have any hardware capabilities. */ -#define _DL_HWCAP_COUNT 0 +static inline int +__attribute__ ((unused)) +_dl_string_hwcap (const char *str) +{ + int i; -#define _dl_string_hwcap(str) (-1) + for (i = 0; i < _DL_HWCAP_COUNT; i++) + { + if (strcmp (str, GLRO(dl_mips_cap_flags)[i]) == 0) + return i; + } + return -1; +}; #endif /* dl-procinfo.h */