Add __rte_flatten, which inlines every call a function makes into it,
where the callee's body is available.

__rte_always_inline marks the callee and inlines it at every call site.
Here the requirement is local to one caller, and the callees are shared
with paths that do not want inlining. Flatten applies at the boundary
that needs it.

A spill slot has a fixed offset on a fixed-width vector ISA. With RVV
its size depends on VLEN and is known only at run time, and once the
frame holds such a slot the rest of it is addressed through vlenb.
Inlining such calls is then worth the code growth.

Signed-off-by: Sun Yuechi <[email protected]>
---
 lib/eal/include/rte_common.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index fed373f412..e32b6b13d6 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -547,6 +547,19 @@ static void __attribute__((destructor(RTE_PRIO(prio)), 
used)) func(void)
 #define __rte_noinline __attribute__((noinline))
 #endif
 
+/**
+ * Inline every call made by a function into it, where the callee's body
+ * is available, whatever the callee's own inline annotation.
+ *
+ * Useful where a call inside a hot loop is costly in itself,
+ * for example where values are held in registers that no call preserves.
+ */
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_flatten
+#else
+#define __rte_flatten __attribute__((flatten))
+#endif
+
 /**
  * Hint function in the hot path
  *
-- 
2.56.0

Reply via email to