* [PATCH 0/2] provide rte_ffs32, rte_ffs64 and __rte_x86_movdiri for MSVC
@ 2024-03-20 21:24 Tyler Retzlaff
2024-03-20 21:24 ` [PATCH 1/2] eal: provide movdiri " Tyler Retzlaff
2024-03-20 21:24 ` [PATCH 2/2] eal: add rte ffs32 and rte ffs64 inline functions Tyler Retzlaff
0 siblings, 2 replies; 3+ messages in thread
From: Tyler Retzlaff @ 2024-03-20 21:24 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, Joyce Kong, Konstantin Ananyev, Tyler Retzlaff
MSVC does not support inline assembly so use movdiri intrinsic and
provide abstracted rte_ffs{32,64} inline functions instead of directly
using GCC built-ins.
Tyler Retzlaff (2):
eal: provide movdiri for MSVC
eal: add rte ffs32 and rte ffs64 inline functions
lib/eal/include/rte_bitops.h | 34 ++++++++++++++++++++++++++++++++++
lib/eal/x86/include/rte_io.h | 4 ++++
2 files changed, 38 insertions(+)
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] eal: provide movdiri for MSVC
2024-03-20 21:24 [PATCH 0/2] provide rte_ffs32, rte_ffs64 and __rte_x86_movdiri for MSVC Tyler Retzlaff
@ 2024-03-20 21:24 ` Tyler Retzlaff
2024-03-20 21:24 ` [PATCH 2/2] eal: add rte ffs32 and rte ffs64 inline functions Tyler Retzlaff
1 sibling, 0 replies; 3+ messages in thread
From: Tyler Retzlaff @ 2024-03-20 21:24 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, Joyce Kong, Konstantin Ananyev, Tyler Retzlaff
MSVC does not support inline assembly instead it provides compiler
intrinsics. Provide conditional compile for MSVC for movdiri using the
_directstoreu_u32 intrinsic.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/eal/x86/include/rte_io.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/eal/x86/include/rte_io.h b/lib/eal/x86/include/rte_io.h
index 0e1fefd..2c72601 100644
--- a/lib/eal/x86/include/rte_io.h
+++ b/lib/eal/x86/include/rte_io.h
@@ -22,11 +22,15 @@
static __rte_always_inline void
__rte_x86_movdiri(uint32_t value, volatile void *addr)
{
+#ifdef RTE_TOOLCHAIN_MSVC
+ _directstoreu_u32((void *)(uintptr_t)addr, value);
+#else
asm volatile(
/* MOVDIRI */
".byte 0x40, 0x0f, 0x38, 0xf9, 0x02"
:
: "a" (value), "d" (addr));
+#endif
}
__rte_experimental
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] eal: add rte ffs32 and rte ffs64 inline functions
2024-03-20 21:24 [PATCH 0/2] provide rte_ffs32, rte_ffs64 and __rte_x86_movdiri for MSVC Tyler Retzlaff
2024-03-20 21:24 ` [PATCH 1/2] eal: provide movdiri " Tyler Retzlaff
@ 2024-03-20 21:24 ` Tyler Retzlaff
1 sibling, 0 replies; 3+ messages in thread
From: Tyler Retzlaff @ 2024-03-20 21:24 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, Joyce Kong, Konstantin Ananyev, Tyler Retzlaff
provide toolchain abstraction for __builtin_ffs{,l,ll} gcc built-in
intrinsics.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/eal/include/rte_bitops.h | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h
index 449565e..e157a45 100644
--- a/lib/eal/include/rte_bitops.h
+++ b/lib/eal/include/rte_bitops.h
@@ -405,6 +405,28 @@
return (unsigned int)__popcnt64(v);
}
+static inline unsigned int
+rte_ffs32(uint32_t v)
+{
+ unsigned long rv;
+
+ if (0 == _BitScanForward(&rv, v))
+ return 0;
+
+ return (unsigned int)rv + 1;
+}
+
+static inline unsigned int
+rte_ffs64(uint64_t v)
+{
+ unsigned long rv;
+
+ if (0 == _BitScanForward64(&rv, v))
+ return 0;
+
+ return (unsigned int)rv + 1;
+}
+
#else
/**
@@ -491,6 +513,18 @@
return (unsigned int)__builtin_popcountll(v);
}
+static inline unsigned int
+rte_ffs32(uint32_t v)
+{
+ return (unsigned int)__builtin_ffs(v);
+}
+
+static inline unsigned int
+rte_ffs64(uint64_t v)
+{
+ return (unsigned int)__builtin_ffsll(v);
+}
+
#endif
/**
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-20 21:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20 21:24 [PATCH 0/2] provide rte_ffs32, rte_ffs64 and __rte_x86_movdiri for MSVC Tyler Retzlaff
2024-03-20 21:24 ` [PATCH 1/2] eal: provide movdiri " Tyler Retzlaff
2024-03-20 21:24 ` [PATCH 2/2] eal: add rte ffs32 and rte ffs64 inline functions Tyler Retzlaff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).