diff mbox series

[V3,15/24] pipeline: create inline functions for instruction operands

Message ID 20210913164443.16875-15-cristian.dumitrescu@intel.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers show
Series [V3,01/24] pipeline: move data structures to internal header file | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dumitrescu, Cristian Sept. 13, 2021, 4:44 p.m. UTC
Create inline functions to get the instruction operands.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/pipeline/rte_swx_pipeline_internal.h | 29 ++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
diff mbox series

Patch

diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h
index 791adfb471..efd136196f 100644
--- a/lib/pipeline/rte_swx_pipeline_internal.h
+++ b/lib/pipeline/rte_swx_pipeline_internal.h
@@ -928,6 +928,35 @@  struct thread {
 #define HEADER_VALID(thread, header_id) \
 	MASK64_BIT_GET((thread)->valid_headers, header_id)
 
+static inline uint64_t
+instr_operand_hbo(struct thread *t, const struct instr_operand *x)
+{
+	uint8_t *x_struct = t->structs[x->struct_id];
+	uint64_t *x64_ptr = (uint64_t *)&x_struct[x->offset];
+	uint64_t x64 = *x64_ptr;
+	uint64_t x64_mask = UINT64_MAX >> (64 - x->n_bits);
+
+	return x64 & x64_mask;
+}
+
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+
+static inline uint64_t
+instr_operand_nbo(struct thread *t, const struct instr_operand *x)
+{
+	uint8_t *x_struct = t->structs[x->struct_id];
+	uint64_t *x64_ptr = (uint64_t *)&x_struct[x->offset];
+	uint64_t x64 = *x64_ptr;
+
+	return ntoh64(x64) >> (64 - x->n_bits);
+}
+
+#else
+
+#define instr_operand_nbo instr_operand_hbo
+
+#endif
+
 #define ALU(thread, ip, operator)  \
 {                                                                              \
 	uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id];      \