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 <kenneth@whitecape.org>
This commit is contained in:
Eric Anholt
2012-05-29 16:18:37 -07:00
parent 279efce8bb
commit 337d9c955b
15 changed files with 57 additions and 0 deletions

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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.
*/

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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.
*/

View File

@@ -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)
{

View File

@@ -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.
*/

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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.
*/