[RFC PATCH 07/19] riscv: hart-features: Add fast_unaligned property
Christoph Muellner
christoph.muellner@vrull.eu
Tue Feb 7 00:16:06 GMT 2023
From: Christoph Müllner <christoph.muellner@vrull.eu>
Having fast unaligned accesses opens the door for a performance
optimizations. Let's add this property to the hart-features
so that this property can be queried using the environment
variable RISCV_RT_FAST_UNALIGNED (e.g. by setting it to "1").
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
sysdeps/unix/sysv/linux/riscv/hart-features.c | 19 +++++++++++++++++++
sysdeps/unix/sysv/linux/riscv/hart-features.h | 5 +++++
2 files changed, 24 insertions(+)
diff --git a/sysdeps/unix/sysv/linux/riscv/hart-features.c b/sysdeps/unix/sysv/linux/riscv/hart-features.c
index 6de41a26cc..b3b7955534 100644
--- a/sysdeps/unix/sysv/linux/riscv/hart-features.c
+++ b/sysdeps/unix/sysv/linux/riscv/hart-features.c
@@ -326,6 +326,22 @@ parse_rt_cboz_blocksize (struct hart_features *hart_features)
hart_features->cboz_blocksize = v;
}
+/* Parse RISCV_RT_FAST_UNALIGNED and store value. */
+static inline void
+parse_rt_fast_unaligned (struct hart_features *hart_features)
+{
+ hart_features->rt_fast_unaligned = NULL;
+ hart_features->fast_unaligned = 0;
+
+ const char *s = simple_getenv ("RISCV_RT_FAST_UNALIGNED");
+ if (s == NULL)
+ return;
+
+ uint64_t v = _dl_strtoul (s, NULL);
+ hart_features->rt_fast_unaligned = s;
+ hart_features->fast_unaligned = v;
+}
+
/* Discover hart features and store them. */
static inline void
init_hart_features (struct hart_features *hart_features)
@@ -334,4 +350,7 @@ init_hart_features (struct hart_features *hart_features)
parse_rt_march (hart_features);
parse_rt_cbom_blocksize (hart_features);
parse_rt_cboz_blocksize (hart_features);
+
+ /* Parse tuning properties. */
+ parse_rt_fast_unaligned (hart_features);
}
diff --git a/sysdeps/unix/sysv/linux/riscv/hart-features.h b/sysdeps/unix/sysv/linux/riscv/hart-features.h
index dd94685676..b2cefd5748 100644
--- a/sysdeps/unix/sysv/linux/riscv/hart-features.h
+++ b/sysdeps/unix/sysv/linux/riscv/hart-features.h
@@ -34,6 +34,9 @@
#define HAVE_CBOZ_BLOCKSIZE(n) \
(GLRO (dl_riscv_hart_features).cboz_blocksize == n)
+#define HAVE_FAST_UNALIGNED() \
+ (GLRO (dl_riscv_hart_features).fast_unaligned != 0)
+
struct hart_features
{
const char* rt_march;
@@ -48,6 +51,8 @@ struct hart_features
unsigned cbom_blocksize;
const char* rt_cboz_blocksize;
unsigned cboz_blocksize;
+ const char* rt_fast_unaligned;
+ unsigned fast_unaligned;
};
#endif /* _CPU_FEATURES_RISCV_H */
--
2.39.1
More information about the Libc-alpha
mailing list