diff options
author | caiyinyu <caiyinyu@loongson.cn> | 2023-09-15 17:35:19 +0800 |
---|---|---|
committer | caiyinyu <caiyinyu@loongson.cn> | 2023-09-19 09:11:49 +0800 |
commit | a53451559dc9cce765ea5bcbb92c4007e058e92b (patch) | |
tree | 4d5b3261a97e362cb36da87962b99a9799a5dc7c /sysdeps/loongarch/dl-machine.h | |
parent | 5bc9b3a1f6a003f6456f717b590615ea98e2d6fb (diff) | |
download | glibc-a53451559dc9cce765ea5bcbb92c4007e058e92b.tar.gz glibc-a53451559dc9cce765ea5bcbb92c4007e058e92b.tar.xz glibc-a53451559dc9cce765ea5bcbb92c4007e058e92b.zip |
LoongArch: Add glibc.cpu.hwcap support.
Key Points: 1. On lasx & lsx platforms, We must use _dl_runtime_{profile, resolve}_{lsx, lasx} to save vector registers. 2. Via "tunables", users can choose str/mem_{lasx,lsx,unaligned} functions with `export GLIBC_TUNABLES=glibc.cpu.hwcaps=LASX,...`. Note: glibc.cpu.hwcaps doesn't affect _dl_runtime_{profile, resolve}_{lsx, lasx} selection. Usage Notes: 1. Only valid inputs: LASX, LSX, UAL. Case-sensitive, comma-separated, no spaces. 2. Example: `export GLIBC_TUNABLES=glibc.cpu.hwcaps=LASX,UAL` turns on LASX & UAL. Unmentioned features turn off. With default ifunc: lasx > lsx > unaligned > aligned > generic, effect is: lasx > unaligned > aligned > generic; lsx off. 3. Incorrect GLIBC_TUNABLES settings will show error messages. For example: On lsx platforms, you cannot enable lasx features. If you do that, you will get error messages. 4. Valid input examples: - GLIBC_TUNABLES=glibc.cpu.hwcaps=LASX: lasx > aligned > generic. - GLIBC_TUNABLES=glibc.cpu.hwcaps=LSX,UAL: lsx > unaligned > aligned > generic. - GLIBC_TUNABLES=glibc.cpu.hwcaps=LASX,UAL,LASX,UAL,LSX,LASX,UAL: Repetitions allowed but not recommended. Results in: lasx > lsx > unaligned > aligned > generic.
Diffstat (limited to 'sysdeps/loongarch/dl-machine.h')
-rw-r--r-- | sysdeps/loongarch/dl-machine.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/sysdeps/loongarch/dl-machine.h b/sysdeps/loongarch/dl-machine.h index 57913cefaa..b395a9283e 100644 --- a/sysdeps/loongarch/dl-machine.h +++ b/sysdeps/loongarch/dl-machine.h @@ -29,6 +29,8 @@ #include <dl-static-tls.h> #include <dl-machine-rel.h> +#include <cpu-features.c> + #ifndef _RTLD_PROLOGUE # define _RTLD_PROLOGUE(entry) \ ".globl\t" __STRING (entry) "\n\t" \ @@ -53,6 +55,23 @@ #define ELF_MACHINE_NO_REL 1 #define ELF_MACHINE_NO_RELA 0 +#define DL_PLATFORM_INIT dl_platform_init () + +static inline void __attribute__ ((unused)) +dl_platform_init (void) +{ + if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0') + /* Avoid an empty string which would disturb us. */ + GLRO(dl_platform) = NULL; + +#ifdef SHARED + /* init_cpu_features has been called early from __libc_start_main in + static executable. */ + init_cpu_features (&GLRO(dl_larch_cpu_features)); +#endif +} + + /* Return nonzero iff ELF header is compatible with the running host. */ static inline int elf_machine_matches_host (const ElfW (Ehdr) *ehdr) @@ -290,9 +309,9 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], if (profile != 0) { #if !defined __loongarch_soft_float - if (SUPPORT_LASX) + if (RTLD_SUPPORT_LASX) gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile_lasx; - else if (SUPPORT_LSX) + else if (RTLD_SUPPORT_LSX) gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile_lsx; else #endif @@ -310,9 +329,9 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], indicated by the offset on the stack, and then jump to the resolved address. */ #if !defined __loongarch_soft_float - if (SUPPORT_LASX) + if (RTLD_SUPPORT_LASX) gotplt[0] = (ElfW(Addr)) &_dl_runtime_resolve_lasx; - else if (SUPPORT_LSX) + else if (RTLD_SUPPORT_LSX) gotplt[0] = (ElfW(Addr)) &_dl_runtime_resolve_lsx; else #endif |