summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac53
1 files changed, 50 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index b89f9a42..0b943ccb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,7 +134,15 @@ if test "$use_mudflap" = fail; then
fi
AM_CONDITIONAL(MUDFLAP, test "$use_mudflap" = yes)
-# Enable gprof suport.
+dnl enable debugging of branch prediction.
+use_debugpred=0
+AC_ARG_ENABLE([debugpred],
+AC_HELP_STRING([--enable-debugpred],
+[build binaries with support to debug branch prediction]),
+[use_debugpred=1], [use_debugpred=0])
+AC_SUBST([DEBUGPRED], $use_debugpred)
+
+dnl Enable gprof suport.
AC_ARG_ENABLE([gprof],
AC_HELP_STRING([--enable-gprof],
[build binaries with gprof support]), [use_gprof=yes], [use_gprof=no])
@@ -267,8 +275,47 @@ AH_BOTTOM([
# define ALLOW_UNALIGNED 0
#endif
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr) __builtin_expect (expr, 1)
+#if DEBUGPRED
+# ifdef __x86_64__
+asm (".section predict_data, \"aw\"; .previous\n"
+ ".section predict_line, \"a\"; .previous\n"
+ ".section predict_file, \"a\"; .previous");
+# ifndef PIC
+# define debugpred__(e, E) \
+ ({ long int _e = !!(e); \
+ asm volatile (".pushsection predict_data; ..predictcnt%=: .quad 0; .quad 0\n" \
+ ".section predict_line; .quad %c1\n" \
+ ".section predict_file; .quad %c2; .popsection\n" \
+ "addq $1,..predictcnt%=(,%0,8)" \
+ : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \
+ __builtin_expect (_e, E); \
+ })
+# endif
+# elif defined __i386__
+asm (".section predict_data, \"aw\"; .previous\n"
+ ".section predict_line, \"a\"; .previous\n"
+ ".section predict_file, \"a\"; .previous");
+# ifndef PIC
+# define debugpred__(e, E) \
+ ({ long int _e = !!(e); \
+ asm volatile (".pushsection predict_data; ..predictcnt%=: .long 0; .long 0\n" \
+ ".section predict_line; .long %c1\n" \
+ ".section predict_file; .long %c2; .popsection\n" \
+ "incl ..predictcnt%=(,%0,8)" \
+ : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \
+ __builtin_expect (_e, E); \
+ })
+# endif
+# endif
+# ifdef debugpred__
+# define unlikely(e) debugpred__ (e,0)
+# define likely(e) debugpred__ (e,1)
+# endif
+#endif
+#ifndef likely
+# define unlikely(expr) __builtin_expect (!!(expr), 0)
+# define likely(expr) __builtin_expect (!!(expr), 1)
+#endif
#define obstack_calloc(ob, size) \
({ size_t _s = (size); memset (obstack_alloc (ob, _s), '\0', _s); })