summaryrefslogtreecommitdiff
path: root/ir_function_inlining.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-04-16 12:53:46 -0700
committerEric Anholt <eric@anholt.net>2010-04-16 12:56:18 -0700
commit0d42321ec1aaeaf60ee2dd8b1872182065ebc057 (patch)
tree84614938e2409734fcb9c9eba62bc470343d5311 /ir_function_inlining.cpp
parent4950a68bf22ede6f4f368c9783e5401816159574 (diff)
Add support for inlining calls done inside of expressions.
Diffstat (limited to 'ir_function_inlining.cpp')
-rw-r--r--ir_function_inlining.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp
index e03673e632..af6a477d9b 100644
--- a/ir_function_inlining.cpp
+++ b/ir_function_inlining.cpp
@@ -31,6 +31,7 @@
#include "ir.h"
#include "ir_visitor.h"
#include "ir_function_inlining.h"
+#include "ir_expression_flattening.h"
#include "glsl_types.h"
class variable_remap : public exec_node {
@@ -305,10 +306,23 @@ can_inline(ir_call *call)
}
bool
+automatic_inlining_predicate(ir_instruction *ir)
+{
+ ir_call *call = ir->as_call();
+
+ if (call && can_inline(call))
+ return true;
+
+ return false;
+}
+
+bool
do_function_inlining(exec_list *instructions)
{
bool progress = false;
+ do_expression_flattening(instructions, automatic_inlining_predicate);
+
foreach_iter(exec_list_iterator, iter, *instructions) {
ir_instruction *ir = (ir_instruction *)iter.get();
ir_assignment *assign = ir->as_assignment();