Merge pull request #702 from pcercuei/update-lightrec-20221029
[pcsx_rearmed.git] / deps / lightrec / lightrec-private.h
index 1b120db..56032f5 100644 (file)
 #include <stdatomic.h>
 #endif
 
+#ifdef _MSC_BUILD
+#include <immintrin.h>
+#endif
+
 #define ARRAY_SIZE(x) (sizeof(x) ? sizeof(x) / sizeof((x)[0]) : 0)
 
+#define GENMASK(h, l) \
+       (((uintptr_t)-1 << (l)) & ((uintptr_t)-1 >> (__WORDSIZE - 1 - (h))))
+
 #ifdef __GNUC__
 #      define likely(x)       __builtin_expect(!!(x),1)
 #      define unlikely(x)     __builtin_expect(!!(x),0)
 
 #ifdef _MSC_BUILD
 #      define popcount32(x)    __popcnt(x)
-#      define ffs32(x)         (31 - __lzcnt(x))
+#      define clz32(x)         _lzcnt_u32(x)
+#      define ctz32(x)         _tzcnt_u32(x)
 #else
 #      define popcount32(x)    __builtin_popcount(x)
-#      define ffs32(x)         (__builtin_ffs(x) - 1)
+#      define clz32(x)         __builtin_clz(x)
+#      define ctz32(x)         __builtin_ctz(x)
 #endif
 
 /* Flags for (struct block *)->flags */
@@ -123,6 +132,7 @@ struct lightrec_branch_target {
 enum c_wrappers {
        C_WRAPPER_RW,
        C_WRAPPER_RW_GENERIC,
+       C_WRAPPER_MFC,
        C_WRAPPER_MTC,
        C_WRAPPER_CP,
        C_WRAPPERS_COUNT,