1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2015 Intel Corporation 3 */ 4 5 #ifndef _RTE_PREFETCH_X86_64_H_ 6 #define _RTE_PREFETCH_X86_64_H_ 7 8 #ifdef RTE_TOOLCHAIN_MSVC 9 #include <emmintrin.h> 10 #endif 11 12 #include <rte_compat.h> 13 #include <rte_common.h> 14 #include "generic/rte_prefetch.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 static inline void rte_prefetch0(const volatile void *p) 21 { 22 #ifdef RTE_TOOLCHAIN_MSVC 23 _mm_prefetch((const char *)(uintptr_t)p, _MM_HINT_T0); 24 #else 25 asm volatile ("prefetcht0 %[p]" : : [p] "m" (*(const volatile char *)p)); 26 #endif 27 } 28 29 static inline void rte_prefetch1(const volatile void *p) 30 { 31 #ifdef RTE_TOOLCHAIN_MSVC 32 _mm_prefetch((const char *)(uintptr_t)p, _MM_HINT_T1); 33 #else 34 asm volatile ("prefetcht1 %[p]" : : [p] "m" (*(const volatile char *)p)); 35 #endif 36 } 37 38 static inline void rte_prefetch2(const volatile void *p) 39 { 40 #ifdef RTE_TOOLCHAIN_MSVC 41 _mm_prefetch((const char *)(uintptr_t)p, _MM_HINT_T2); 42 #else 43 asm volatile ("prefetcht2 %[p]" : : [p] "m" (*(const volatile char *)p)); 44 #endif 45 } 46 47 static inline void rte_prefetch_non_temporal(const volatile void *p) 48 { 49 #ifdef RTE_TOOLCHAIN_MSVC 50 _mm_prefetch((const char *)(uintptr_t)p, _MM_HINT_NTA); 51 #else 52 asm volatile ("prefetchnta %[p]" : : [p] "m" (*(const volatile char *)p)); 53 #endif 54 } 55 56 __rte_experimental 57 static inline void 58 rte_cldemote(const volatile void *p) 59 { 60 #ifdef RTE_TOOLCHAIN_MSVC 61 _mm_cldemote((const void *)(uintptr_t)p); 62 #else 63 /* 64 * We use raw byte codes for now as only the newest compiler 65 * versions support this instruction natively. 66 */ 67 asm volatile(".byte 0x0f, 0x1c, 0x06" :: "S" (p)); 68 #endif 69 } 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif /* _RTE_PREFETCH_X86_64_H_ */ 76