Signed-off-by: Martin Storsjö <[email protected]>
---
 mingw-w64-headers/crt/_mingw.h.in | 19 +++++++++++++++++++
 mingw-w64-headers/crt/intrin.h    |  1 +
 2 files changed, 20 insertions(+)

diff --git a/mingw-w64-headers/crt/_mingw.h.in 
b/mingw-w64-headers/crt/_mingw.h.in
index 087fce88d..3a83bbeff 100644
--- a/mingw-w64-headers/crt/_mingw.h.in
+++ b/mingw-w64-headers/crt/_mingw.h.in
@@ -622,6 +622,25 @@ __MINGW_INTRIN_INLINE void __cdecl __MINGW_ATTRIB_NORETURN 
__fastfail(unsigned i
 }
 #endif /* __MINGW_FASTFAIL_IMPL == 1 */
 
+#ifdef __has_builtin
+#define __MINGW_PREFETCH_IMPL !__has_builtin(__prefetch)
+#else
+#define __MINGW_PREFETCH_IMPL 1
+#endif
+#if __MINGW_PREFETCH_IMPL == 1
+#if defined(__arm__) || defined(__aarch64__)
+void __cdecl __prefetch(const void *addr);
+__MINGW_INTRIN_INLINE void __cdecl __prefetch(const void *addr)
+{
+#if defined(__arm__)
+  __asm__ __volatile__("pld [%0]"::"r"(addr));
+#elif defined(__aarch64__)
+  __asm__ __volatile__("prfm pldl1keep, [%0]"::"r"(addr));
+#endif
+}
+#endif /* defined(__arm__) || defined(__aarch64__) */
+#endif /* __MINGW_PREFETCH_IMPL == 1 */
+
 #endif /* defined(__MINGW_INTRIN_INLINE) */
 
 /* mingw-w64 specific functions: */
diff --git a/mingw-w64-headers/crt/intrin.h b/mingw-w64-headers/crt/intrin.h
index 5dcbca9b0..69653e440 100644
--- a/mingw-w64-headers/crt/intrin.h
+++ b/mingw-w64-headers/crt/intrin.h
@@ -504,6 +504,7 @@ extern "C" {
     __MACHINEI(unsigned short __cdecl _outpw(unsigned short,unsigned short))
     __MACHINEI(unsigned short __cdecl outpw(unsigned short,unsigned short))
     __MACHINECE(void __cdecl __prefetch(unsigned long *addr))
+    __MACHINEARM_ARM64(void __cdecl __prefetch(const void *addr))
     __MACHINEIA64(__MINGW_EXTENSION void __ptcl(__int64,__int64))
     __MACHINEIA64(__MINGW_EXTENSION void __ptcg(__int64,__int64))
     __MACHINEIA64(__MINGW_EXTENSION void __ptcga(__int64,__int64))
-- 
2.25.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to