aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-05-29 16:18:37 -0700
committerEric Anholt <[email protected]>2012-06-11 09:28:00 -0700
commit337d9c955b070224f7278524af54ddacd8bb0f17 (patch)
tree4235c18837cc1f81b0c2f008cc01ce7a6e3a39a8 /src/glsl
parent279efce8bb7b6c802eb6c1de46971153ff6fdedb (diff)
glsl: Put a bunch of optimization visitors under anonymous namespaces.
Because these classes are used entirely from their own source files and not from separate DSOs, the linker gets to produce massively less code. This cuts about 13k of text in the libdricore case. In the non-libdricore case, the additional linkage information allows the compiler to inline some code, so libglsl.a size actually increases by about 300 bytes. For a dricore build, improves shader_runner runtime on glsl-fs-copy-propagation-texcoords-1 by 0.21% +/- 0.03% (n=353574, outliers removed). No statistically significant difference with n=322 on glslparsertest on a yofrankie shader intended to test compiler performance. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/opt_algebraic.cpp4
-rw-r--r--src/glsl/opt_constant_folding.cpp4
-rw-r--r--src/glsl/opt_constant_propagation.cpp4
-rw-r--r--src/glsl/opt_constant_variable.cpp4
-rw-r--r--src/glsl/opt_copy_propagation.cpp4
-rw-r--r--src/glsl/opt_copy_propagation_elements.cpp4
-rw-r--r--src/glsl/opt_dead_code_local.cpp3
-rw-r--r--src/glsl/opt_dead_functions.cpp3
-rw-r--r--src/glsl/opt_function_inlining.cpp3
-rw-r--r--src/glsl/opt_if_simplification.cpp4
-rw-r--r--src/glsl/opt_noop_swizzle.cpp4
-rw-r--r--src/glsl/opt_redundant_jumps.cpp4
-rw-r--r--src/glsl/opt_structure_splitting.cpp4
-rw-r--r--src/glsl/opt_swizzle_swizzle.cpp4
-rw-r--r--src/glsl/opt_tree_grafting.cpp4
15 files changed, 57 insertions, 0 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index cade9611dbb..d3976126050 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -34,6 +34,8 @@
#include "ir_optimization.h"
#include "glsl_types.h"
+namespace {
+
/**
* Visitor class for replacing expressions with ir_constant values.
*/
@@ -68,6 +70,8 @@ public:
bool progress;
};
+} /* unnamed namespace */
+
static inline bool
is_vec_zero(ir_constant *ir)
{
diff --git a/src/glsl/opt_constant_folding.cpp b/src/glsl/opt_constant_folding.cpp
index dcad59997f1..7d94d481c9f 100644
--- a/src/glsl/opt_constant_folding.cpp
+++ b/src/glsl/opt_constant_folding.cpp
@@ -32,6 +32,8 @@
#include "ir_optimization.h"
#include "glsl_types.h"
+namespace {
+
/**
* Visitor class for replacing expressions with ir_constant values.
*/
@@ -56,6 +58,8 @@ public:
bool progress;
};
+} /* unnamed namespace */
+
void
ir_constant_folding_visitor::handle_rvalue(ir_rvalue **rvalue)
{
diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp
index 2601b52f6d3..c5ae36b692c 100644
--- a/src/glsl/opt_constant_propagation.cpp
+++ b/src/glsl/opt_constant_propagation.cpp
@@ -41,6 +41,8 @@
#include "ir_optimization.h"
#include "glsl_types.h"
+namespace {
+
class acp_entry : public exec_node
{
public:
@@ -450,6 +452,8 @@ ir_constant_propagation_visitor::add_constant(ir_assignment *ir)
this->acp->push_tail(entry);
}
+} /* unnamed namespace */
+
/**
* Does a constant propagation pass on the code present in the instruction stream.
*/
diff --git a/src/glsl/opt_constant_variable.cpp b/src/glsl/opt_constant_variable.cpp
index f3bc8675efd..1bbaf8e4792 100644
--- a/src/glsl/opt_constant_variable.cpp
+++ b/src/glsl/opt_constant_variable.cpp
@@ -37,6 +37,8 @@
#include "ir_optimization.h"
#include "glsl_types.h"
+namespace {
+
struct assignment_entry {
exec_node link;
int assignment_count;
@@ -55,6 +57,8 @@ public:
exec_list list;
};
+} /* unnamed namespace */
+
static struct assignment_entry *
get_assignment_entry(ir_variable *var, exec_list *list)
{
diff --git a/src/glsl/opt_copy_propagation.cpp b/src/glsl/opt_copy_propagation.cpp
index 923619db45a..2952ce594f7 100644
--- a/src/glsl/opt_copy_propagation.cpp
+++ b/src/glsl/opt_copy_propagation.cpp
@@ -38,6 +38,8 @@
#include "ir_optimization.h"
#include "glsl_types.h"
+namespace {
+
class acp_entry : public exec_node
{
public:
@@ -107,6 +109,8 @@ public:
void *mem_ctx;
};
+} /* unnamed namespace */
+
ir_visitor_status
ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir)
{
diff --git a/src/glsl/opt_copy_propagation_elements.cpp b/src/glsl/opt_copy_propagation_elements.cpp
index 11d9d7baf72..de9f4ef6f67 100644
--- a/src/glsl/opt_copy_propagation_elements.cpp
+++ b/src/glsl/opt_copy_propagation_elements.cpp
@@ -49,6 +49,8 @@
static bool debug = false;
+namespace {
+
class acp_entry : public exec_node
{
public:
@@ -135,6 +137,8 @@ public:
void *shader_mem_ctx;
};
+} /* unnamed namespace */
+
ir_visitor_status
ir_copy_propagation_elements_visitor::visit_enter(ir_function_signature *ir)
{
diff --git a/src/glsl/opt_dead_code_local.cpp b/src/glsl/opt_dead_code_local.cpp
index 4af78a72cc3..8c31802a6ac 100644
--- a/src/glsl/opt_dead_code_local.cpp
+++ b/src/glsl/opt_dead_code_local.cpp
@@ -40,6 +40,8 @@
static bool debug = false;
+namespace {
+
class assignment_entry : public exec_node
{
public:
@@ -138,6 +140,7 @@ public:
ir_hierarchical_visitor *visitor;
};
+} /* unnamed namespace */
/**
* Adds an entry to the available copy list if it's a plain assignment
diff --git a/src/glsl/opt_dead_functions.cpp b/src/glsl/opt_dead_functions.cpp
index f503493957b..cd3b2c12e89 100644
--- a/src/glsl/opt_dead_functions.cpp
+++ b/src/glsl/opt_dead_functions.cpp
@@ -32,6 +32,8 @@
#include "ir_expression_flattening.h"
#include "glsl_types.h"
+namespace {
+
class signature_entry : public exec_node
{
public:
@@ -67,6 +69,7 @@ public:
void *mem_ctx;
};
+} /* unnamed namespace */
signature_entry *
ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig)
diff --git a/src/glsl/opt_function_inlining.cpp b/src/glsl/opt_function_inlining.cpp
index 4ff4d97d9bc..f9f5bd44267 100644
--- a/src/glsl/opt_function_inlining.cpp
+++ b/src/glsl/opt_function_inlining.cpp
@@ -39,6 +39,8 @@ do_sampler_replacement(exec_list *instructions,
ir_variable *sampler,
ir_dereference *deref);
+namespace {
+
class ir_function_inlining_visitor : public ir_hierarchical_visitor {
public:
ir_function_inlining_visitor()
@@ -60,6 +62,7 @@ public:
bool progress;
};
+} /* unnamed namespace */
bool
do_function_inlining(exec_list *instructions)
diff --git a/src/glsl/opt_if_simplification.cpp b/src/glsl/opt_if_simplification.cpp
index 7e88208f7c1..e1a23d94a98 100644
--- a/src/glsl/opt_if_simplification.cpp
+++ b/src/glsl/opt_if_simplification.cpp
@@ -30,6 +30,8 @@
#include "ir.h"
+namespace {
+
class ir_if_simplification_visitor : public ir_hierarchical_visitor {
public:
ir_if_simplification_visitor()
@@ -43,6 +45,8 @@ public:
bool made_progress;
};
+} /* unnamed namespace */
+
/* We only care about the top level "if" instructions, so don't
* descend into expressions.
*/
diff --git a/src/glsl/opt_noop_swizzle.cpp b/src/glsl/opt_noop_swizzle.cpp
index 0a906aaf1da..693719e3dc7 100644
--- a/src/glsl/opt_noop_swizzle.cpp
+++ b/src/glsl/opt_noop_swizzle.cpp
@@ -35,6 +35,8 @@
#include "ir_print_visitor.h"
#include "glsl_types.h"
+namespace {
+
class ir_noop_swizzle_visitor : public ir_rvalue_visitor {
public:
ir_noop_swizzle_visitor()
@@ -46,6 +48,8 @@ public:
bool progress;
};
+} /* unnamed namespace */
+
void
ir_noop_swizzle_visitor::handle_rvalue(ir_rvalue **rvalue)
{
diff --git a/src/glsl/opt_redundant_jumps.cpp b/src/glsl/opt_redundant_jumps.cpp
index f350fa947c9..8606dcbb71d 100644
--- a/src/glsl/opt_redundant_jumps.cpp
+++ b/src/glsl/opt_redundant_jumps.cpp
@@ -28,6 +28,8 @@
#include "ir.h"
+namespace {
+
class redundant_jumps_visitor : public ir_hierarchical_visitor {
public:
redundant_jumps_visitor()
@@ -42,6 +44,8 @@ public:
bool progress;
};
+} /* unnamed namespace */
+
/* We only care about the top level instructions, so don't descend
* into expressions.
*/
diff --git a/src/glsl/opt_structure_splitting.cpp b/src/glsl/opt_structure_splitting.cpp
index a21238dd0aa..60eec53b72a 100644
--- a/src/glsl/opt_structure_splitting.cpp
+++ b/src/glsl/opt_structure_splitting.cpp
@@ -38,6 +38,8 @@
#include "ir_rvalue_visitor.h"
#include "glsl_types.h"
+namespace {
+
static bool debug = false;
// XXX using variable_entry2 here to avoid collision (MSVC multiply-defined
@@ -307,6 +309,8 @@ ir_structure_splitting_visitor::visit_leave(ir_assignment *ir)
return visit_continue;
}
+} /* unnamed namespace */
+
bool
do_structure_splitting(exec_list *instructions)
{
diff --git a/src/glsl/opt_swizzle_swizzle.cpp b/src/glsl/opt_swizzle_swizzle.cpp
index bc442fa8693..7564c6b3b10 100644
--- a/src/glsl/opt_swizzle_swizzle.cpp
+++ b/src/glsl/opt_swizzle_swizzle.cpp
@@ -32,6 +32,8 @@
#include "ir_optimization.h"
#include "glsl_types.h"
+namespace {
+
class ir_swizzle_swizzle_visitor : public ir_hierarchical_visitor {
public:
ir_swizzle_swizzle_visitor()
@@ -44,6 +46,8 @@ public:
bool progress;
};
+} /* unnamed namespace */
+
ir_visitor_status
ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir)
{
diff --git a/src/glsl/opt_tree_grafting.cpp b/src/glsl/opt_tree_grafting.cpp
index d86eab80e50..25b18ea940c 100644
--- a/src/glsl/opt_tree_grafting.cpp
+++ b/src/glsl/opt_tree_grafting.cpp
@@ -54,6 +54,8 @@
#include "ir_optimization.h"
#include "glsl_types.h"
+namespace {
+
static bool debug = false;
class ir_tree_grafting_visitor : public ir_hierarchical_visitor {
@@ -369,6 +371,8 @@ tree_grafting_basic_block(ir_instruction *bb_first,
}
}
+} /* unnamed namespace */
+
/**
* Does a copy propagation pass on the code present in the instruction stream.
*/