#include "ir_expression_flattening.h"
#include "glsl_types.h"
+namespace {
+
class signature_entry : public exec_node
{
public:
ir_dead_functions_visitor()
{
this->mem_ctx = ralloc_context(NULL);
- this->seen_another_function_signature = false;
}
~ir_dead_functions_visitor()
signature_entry *get_signature_entry(ir_function_signature *var);
- bool (*predicate)(ir_instruction *ir);
-
- bool seen_another_function_signature;
-
/* List of signature_entry */
exec_list signature_list;
void *mem_ctx;
};
+} /* unnamed namespace */
signature_entry *
ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig)
{
- foreach_iter(exec_list_iterator, iter, this->signature_list) {
- signature_entry *entry = (signature_entry *)iter.get();
+ foreach_list(n, &this->signature_list) {
+ signature_entry *entry = (signature_entry *) n;
if (entry->signature == sig)
return entry;
}
entry->used = true;
}
- /* If this is the first signature to look at, no need to descend to see
- * if it has calls to another function signature.
- */
- if (!this->seen_another_function_signature) {
- this->seen_another_function_signature = true;
- return visit_continue_with_parent;
- }
+
return visit_continue;
}
ir_visitor_status
ir_dead_functions_visitor::visit_enter(ir_call *ir)
{
- signature_entry *entry = this->get_signature_entry(ir->get_callee());
+ signature_entry *entry = this->get_signature_entry(ir->callee);
entry->used = true;
* the unused ones, and remove function definitions that have no more
* signatures.
*/
- foreach_iter(exec_list_iterator, iter, v.signature_list) {
- signature_entry *entry = (signature_entry *)iter.get();
+ foreach_list_safe(n, &v.signature_list) {
+ signature_entry *entry = (signature_entry *) n;
if (!entry->used) {
entry->signature->remove();
/* We don't just do this above when we nuked a signature because of
* const pointers.
*/
- foreach_iter(exec_list_iterator, iter, *instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list_safe(n, instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
ir_function *func = ir->as_function();
if (func && func->signatures.is_empty()) {