Commit 337d9c95 authored by Eric Anholt's avatar Eric Anholt

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's avatarKenneth Graunke <kenneth@whitecape.org>
parent 279efce8
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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.
*/
......
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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.
*/
......
......@@ -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)
{
......
......@@ -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.
*/
......
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment