aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/util')
-rw-r--r--mesalib/src/util/Makefile.am6
-rw-r--r--mesalib/src/util/SConscript2
-rw-r--r--mesalib/src/util/bitset.h2
-rw-r--r--mesalib/src/util/macros.h23
-rw-r--r--mesalib/src/util/register_allocate.c24
-rw-r--r--mesalib/src/util/register_allocate.h10
6 files changed, 64 insertions, 3 deletions
diff --git a/mesalib/src/util/Makefile.am b/mesalib/src/util/Makefile.am
index 9af233059..ec49dc6cf 100644
--- a/mesalib/src/util/Makefile.am
+++ b/mesalib/src/util/Makefile.am
@@ -25,6 +25,9 @@ include Makefile.sources
noinst_LTLIBRARIES = libmesautil.la
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include
+
libmesautil_la_CPPFLAGS = \
$(DEFINES) \
-I$(top_srcdir)/include \
@@ -34,7 +37,8 @@ libmesautil_la_CPPFLAGS = \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
$(SHA1_CFLAGS) \
- $(VISIBILITY_CFLAGS)
+ $(VISIBILITY_CFLAGS) \
+ $(MSVC2008_COMPAT_CFLAGS)
libmesautil_la_SOURCES = \
$(MESA_UTIL_FILES) \
diff --git a/mesalib/src/util/SConscript b/mesalib/src/util/SConscript
index 84bd7a1e1..9e4d481f8 100644
--- a/mesalib/src/util/SConscript
+++ b/mesalib/src/util/SConscript
@@ -6,6 +6,8 @@ from sys import executable as python_cmd
env = env.Clone()
+env.MSVC2008Compat()
+
env.Prepend(CPPPATH = [
'#include',
'#src',
diff --git a/mesalib/src/util/bitset.h b/mesalib/src/util/bitset.h
index 17c5d5d25..febcddefd 100644
--- a/mesalib/src/util/bitset.h
+++ b/mesalib/src/util/bitset.h
@@ -94,6 +94,6 @@ __bitset_ffs(const BITSET_WORD *x, int n)
return 0;
}
-#define BITSET_FFS(x) __bitset_ffs(x, Elements(x))
+#define BITSET_FFS(x) __bitset_ffs(x, ARRAY_SIZE(x))
#endif
diff --git a/mesalib/src/util/macros.h b/mesalib/src/util/macros.h
index eec8b9352..b862bfd5f 100644
--- a/mesalib/src/util/macros.h
+++ b/mesalib/src/util/macros.h
@@ -156,4 +156,27 @@ do { \
# endif
#endif
+/**
+ * PUBLIC/USED macros
+ *
+ * If we build the library with gcc's -fvisibility=hidden flag, we'll
+ * use the PUBLIC macro to mark functions that are to be exported.
+ *
+ * We also need to define a USED attribute, so the optimizer doesn't
+ * inline a static function that we later use in an alias. - ajax
+ */
+#ifndef PUBLIC
+# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+# define PUBLIC __attribute__((visibility("default")))
+# define USED __attribute__((used))
+# elif defined(_MSC_VER)
+# define PUBLIC __declspec(dllexport)
+# define USED
+# else
+# define PUBLIC
+# define USED
+# endif
+#endif
+
+
#endif /* UTIL_MACROS_H */
diff --git a/mesalib/src/util/register_allocate.c b/mesalib/src/util/register_allocate.c
index 684ee5d6c..2ad8c3ce1 100644
--- a/mesalib/src/util/register_allocate.c
+++ b/mesalib/src/util/register_allocate.c
@@ -168,6 +168,12 @@ struct ra_graph {
unsigned int *stack;
unsigned int stack_count;
+
+ /**
+ * Tracks the start of the set of optimistically-colored registers in the
+ * stack.
+ */
+ unsigned int stack_optimistic_start;
};
/**
@@ -454,6 +460,7 @@ static void
ra_simplify(struct ra_graph *g)
{
bool progress = true;
+ unsigned int stack_optimistic_start = UINT_MAX;
int i;
while (progress) {
@@ -482,6 +489,9 @@ ra_simplify(struct ra_graph *g)
}
if (!progress && best_optimistic_node != ~0U) {
+ if (stack_optimistic_start == UINT_MAX)
+ stack_optimistic_start = g->stack_count;
+
decrement_q(g, best_optimistic_node);
g->stack[g->stack_count] = best_optimistic_node;
g->stack_count++;
@@ -489,6 +499,8 @@ ra_simplify(struct ra_graph *g)
progress = true;
}
}
+
+ g->stack_optimistic_start = stack_optimistic_start;
}
/**
@@ -542,7 +554,17 @@ ra_select(struct ra_graph *g)
g->nodes[n].reg = r;
g->stack_count--;
- if (g->regs->round_robin)
+ /* Rotate the starting point except for any nodes above the lowest
+ * optimistically colorable node. The likelihood that we will succeed
+ * at allocating optimistically colorable nodes is highly dependent on
+ * the way that the previous nodes popped off the stack are laid out.
+ * The round-robin strategy increases the fragmentation of the register
+ * file and decreases the number of nearby nodes assigned to the same
+ * color, what increases the likelihood of spilling with respect to the
+ * dense packing strategy.
+ */
+ if (g->regs->round_robin &&
+ g->stack_count - 1 <= g->stack_optimistic_start)
start_search_reg = r + 1;
}
diff --git a/mesalib/src/util/register_allocate.h b/mesalib/src/util/register_allocate.h
index dc6874495..61f182eff 100644
--- a/mesalib/src/util/register_allocate.h
+++ b/mesalib/src/util/register_allocate.h
@@ -27,6 +27,12 @@
#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct ra_class;
struct ra_regs;
@@ -77,3 +83,7 @@ void ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost);
int ra_get_best_spill_node(struct ra_graph *g);
/** @} */
+
+#ifdef __cplusplus
+} // extern "C"
+#endif