Move optimization pass prototypes to a single header.
This commit is contained in:
@@ -34,11 +34,6 @@
|
|||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
#include "glsl_parser_extras.h"
|
#include "glsl_parser_extras.h"
|
||||||
#include "glsl_parser.h"
|
#include "glsl_parser.h"
|
||||||
#include "ir_constant_folding.h"
|
|
||||||
#include "ir_copy_propagation.h"
|
|
||||||
#include "ir_dead_code.h"
|
|
||||||
#include "ir_function_inlining.h"
|
|
||||||
#include "ir_if_simplification.h"
|
|
||||||
#include "ir_optimization.h"
|
#include "ir_optimization.h"
|
||||||
#include "ir_print_visitor.h"
|
#include "ir_print_visitor.h"
|
||||||
#include "ir_reader.h"
|
#include "ir_reader.h"
|
||||||
@@ -791,10 +786,7 @@ main(int argc, char **argv)
|
|||||||
progress = do_copy_propagation(&instructions) || progress;
|
progress = do_copy_propagation(&instructions) || progress;
|
||||||
progress = do_dead_code_local(&instructions) || progress;
|
progress = do_dead_code_local(&instructions) || progress;
|
||||||
progress = do_dead_code_unlinked(&instructions) || progress;
|
progress = do_dead_code_unlinked(&instructions) || progress;
|
||||||
|
progress = do_constant_folding(&instructions) || progress;
|
||||||
/* Constant folding */
|
|
||||||
ir_constant_folding_visitor constant_folding;
|
|
||||||
visit_exec_list(&instructions, &constant_folding);
|
|
||||||
} while (progress);
|
} while (progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,13 +29,49 @@
|
|||||||
#define NULL 0
|
#define NULL 0
|
||||||
#include "ir.h"
|
#include "ir.h"
|
||||||
#include "ir_visitor.h"
|
#include "ir_visitor.h"
|
||||||
#include "ir_constant_folding.h"
|
#include "ir_optimization.h"
|
||||||
#include "glsl_types.h"
|
#include "glsl_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visitor class for replacing expressions with ir_constant values.
|
* Visitor class for replacing expressions with ir_constant values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class ir_constant_folding_visitor : public ir_visitor {
|
||||||
|
public:
|
||||||
|
ir_constant_folding_visitor()
|
||||||
|
{
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~ir_constant_folding_visitor()
|
||||||
|
{
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Visit methods
|
||||||
|
*
|
||||||
|
* As typical for the visitor pattern, there must be one \c visit method for
|
||||||
|
* each concrete subclass of \c ir_instruction. Virtual base classes within
|
||||||
|
* the hierarchy should not have \c visit methods.
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
virtual void visit(ir_variable *);
|
||||||
|
virtual void visit(ir_function_signature *);
|
||||||
|
virtual void visit(ir_function *);
|
||||||
|
virtual void visit(ir_expression *);
|
||||||
|
virtual void visit(ir_swizzle *);
|
||||||
|
virtual void visit(ir_dereference *);
|
||||||
|
virtual void visit(ir_assignment *);
|
||||||
|
virtual void visit(ir_constant *);
|
||||||
|
virtual void visit(ir_call *);
|
||||||
|
virtual void visit(ir_return *);
|
||||||
|
virtual void visit(ir_if *);
|
||||||
|
virtual void visit(ir_loop *);
|
||||||
|
virtual void visit(ir_loop_jump *);
|
||||||
|
/*@}*/
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
ir_constant_folding_visitor::visit(ir_variable *ir)
|
ir_constant_folding_visitor::visit(ir_variable *ir)
|
||||||
{
|
{
|
||||||
@@ -152,3 +188,14 @@ ir_constant_folding_visitor::visit(ir_loop_jump *ir)
|
|||||||
{
|
{
|
||||||
(void) ir;
|
(void) ir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
do_constant_folding(exec_list *instructions)
|
||||||
|
{
|
||||||
|
ir_constant_folding_visitor constant_folding;
|
||||||
|
|
||||||
|
visit_exec_list(instructions, &constant_folding);
|
||||||
|
|
||||||
|
/* FINISHME: Return real progress. */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2010 Intel Corporation
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation
|
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the next
|
|
||||||
* paragraph) shall be included in all copies or substantial portions of the
|
|
||||||
* Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file ir_constant_folding.h
|
|
||||||
* Replace constant-valued expressions with references to constant values.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ir_constant_folding_visitor : public ir_visitor {
|
|
||||||
public:
|
|
||||||
ir_constant_folding_visitor()
|
|
||||||
{
|
|
||||||
/* empty */
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~ir_constant_folding_visitor()
|
|
||||||
{
|
|
||||||
/* empty */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \name Visit methods
|
|
||||||
*
|
|
||||||
* As typical for the visitor pattern, there must be one \c visit method for
|
|
||||||
* each concrete subclass of \c ir_instruction. Virtual base classes within
|
|
||||||
* the hierarchy should not have \c visit methods.
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
virtual void visit(ir_variable *);
|
|
||||||
virtual void visit(ir_function_signature *);
|
|
||||||
virtual void visit(ir_function *);
|
|
||||||
virtual void visit(ir_expression *);
|
|
||||||
virtual void visit(ir_swizzle *);
|
|
||||||
virtual void visit(ir_dereference *);
|
|
||||||
virtual void visit(ir_assignment *);
|
|
||||||
virtual void visit(ir_constant *);
|
|
||||||
virtual void visit(ir_call *);
|
|
||||||
virtual void visit(ir_return *);
|
|
||||||
virtual void visit(ir_if *);
|
|
||||||
virtual void visit(ir_loop *);
|
|
||||||
virtual void visit(ir_loop_jump *);
|
|
||||||
/*@}*/
|
|
||||||
};
|
|
@@ -37,7 +37,7 @@
|
|||||||
#include "ir_visitor.h"
|
#include "ir_visitor.h"
|
||||||
#include "ir_print_visitor.h"
|
#include "ir_print_visitor.h"
|
||||||
#include "ir_basic_block.h"
|
#include "ir_basic_block.h"
|
||||||
#include "ir_copy_propagation.h"
|
#include "ir_optimization.h"
|
||||||
#include "glsl_types.h"
|
#include "glsl_types.h"
|
||||||
|
|
||||||
class acp_entry : public exec_node
|
class acp_entry : public exec_node
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2010 Intel Corporation
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation
|
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the next
|
|
||||||
* paragraph) shall be included in all copies or substantial portions of the
|
|
||||||
* Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool do_copy_propagation(exec_list *instructions);
|
|
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2010 Intel Corporation
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation
|
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the next
|
|
||||||
* paragraph) shall be included in all copies or substantial portions of the
|
|
||||||
* Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file ir_dead_code.h
|
|
||||||
*
|
|
||||||
* Eliminates dead assignments and variable declarations from the code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool do_dead_code(exec_list *instructions);
|
|
||||||
bool do_dead_code_unlinked(exec_list *instructions);
|
|
@@ -34,6 +34,42 @@
|
|||||||
#include "ir_expression_flattening.h"
|
#include "ir_expression_flattening.h"
|
||||||
#include "glsl_types.h"
|
#include "glsl_types.h"
|
||||||
|
|
||||||
|
class ir_function_inlining_visitor : public ir_visitor {
|
||||||
|
public:
|
||||||
|
ir_function_inlining_visitor()
|
||||||
|
{
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~ir_function_inlining_visitor()
|
||||||
|
{
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Visit methods
|
||||||
|
*
|
||||||
|
* As typical for the visitor pattern, there must be one \c visit method for
|
||||||
|
* each concrete subclass of \c ir_instruction. Virtual base classes within
|
||||||
|
* the hierarchy should not have \c visit methods.
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
virtual void visit(ir_variable *);
|
||||||
|
virtual void visit(ir_loop *);
|
||||||
|
virtual void visit(ir_loop_jump *);
|
||||||
|
virtual void visit(ir_function_signature *);
|
||||||
|
virtual void visit(ir_function *);
|
||||||
|
virtual void visit(ir_expression *);
|
||||||
|
virtual void visit(ir_swizzle *);
|
||||||
|
virtual void visit(ir_dereference *);
|
||||||
|
virtual void visit(ir_assignment *);
|
||||||
|
virtual void visit(ir_constant *);
|
||||||
|
virtual void visit(ir_call *);
|
||||||
|
virtual void visit(ir_return *);
|
||||||
|
virtual void visit(ir_if *);
|
||||||
|
/*@}*/
|
||||||
|
};
|
||||||
|
|
||||||
class variable_remap : public exec_node {
|
class variable_remap : public exec_node {
|
||||||
public:
|
public:
|
||||||
variable_remap(const ir_variable *old_var, ir_variable *new_var)
|
variable_remap(const ir_variable *old_var, ir_variable *new_var)
|
||||||
|
@@ -27,41 +27,4 @@
|
|||||||
* Replaces calls to functions with the body of the function.
|
* Replaces calls to functions with the body of the function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ir_function_inlining_visitor : public ir_visitor {
|
|
||||||
public:
|
|
||||||
ir_function_inlining_visitor()
|
|
||||||
{
|
|
||||||
/* empty */
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~ir_function_inlining_visitor()
|
|
||||||
{
|
|
||||||
/* empty */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \name Visit methods
|
|
||||||
*
|
|
||||||
* As typical for the visitor pattern, there must be one \c visit method for
|
|
||||||
* each concrete subclass of \c ir_instruction. Virtual base classes within
|
|
||||||
* the hierarchy should not have \c visit methods.
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
virtual void visit(ir_variable *);
|
|
||||||
virtual void visit(ir_loop *);
|
|
||||||
virtual void visit(ir_loop_jump *);
|
|
||||||
virtual void visit(ir_function_signature *);
|
|
||||||
virtual void visit(ir_function *);
|
|
||||||
virtual void visit(ir_expression *);
|
|
||||||
virtual void visit(ir_swizzle *);
|
|
||||||
virtual void visit(ir_dereference *);
|
|
||||||
virtual void visit(ir_assignment *);
|
|
||||||
virtual void visit(ir_constant *);
|
|
||||||
virtual void visit(ir_call *);
|
|
||||||
virtual void visit(ir_return *);
|
|
||||||
virtual void visit(ir_if *);
|
|
||||||
/*@}*/
|
|
||||||
};
|
|
||||||
|
|
||||||
bool do_function_inlining(exec_list *instructions);
|
|
||||||
bool can_inline(ir_call *call);
|
bool can_inline(ir_call *call);
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2010 Intel Corporation
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation
|
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the next
|
|
||||||
* paragraph) shall be included in all copies or substantial portions of the
|
|
||||||
* Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file ir_if_simplification.h
|
|
||||||
*
|
|
||||||
* Moves constant branches of if statements out to the surrounding
|
|
||||||
* instruction stream.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool do_if_simplification(exec_list *instructions);
|
|
@@ -28,4 +28,10 @@
|
|||||||
* Prototypes for optimization passes to be called by the compiler and drivers.
|
* Prototypes for optimization passes to be called by the compiler and drivers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
bool do_constant_folding(exec_list *instructions);
|
||||||
|
bool do_copy_propagation(exec_list *instructions);
|
||||||
|
bool do_dead_code(exec_list *instructions);
|
||||||
bool do_dead_code_local(exec_list *instructions);
|
bool do_dead_code_local(exec_list *instructions);
|
||||||
|
bool do_dead_code_unlinked(exec_list *instructions);
|
||||||
|
bool do_function_inlining(exec_list *instructions);
|
||||||
|
bool do_if_simplification(exec_list *instructions);
|
||||||
|
Reference in New Issue
Block a user